Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
count =0
while B != A: 
    if max(B) < max(A):
        count =-1
        break
    i = B.index(max(B))
    if i+1 >= N:
        B[i] = B[i] - B[0] - B[i-1]
    else:
        B[i] = B[i] - B[i+1] - B[i-1]
    count += 1
    
print(count)

Fixed submission:
S = input()
count = 1
strings = []
strings.append(S[0])
stack = ''
for s in S[1:]:
    stack += s
    if strings[-1] == stack:
        continue
    else:
        strings.append(stack)
        stack = ''
        count+=1    

print(count)

Buggy python submission (verdict: Runtime Error):
S = input()
count = 0
i = 0
while i < len(S)-2:
    if S[i] == S[i+1]:
        i +=3
        count += 2  
    else:
        i +=1
        count += 1
if S[i] == S[i+1]:
    count += 1
else:
    count += 2
print(count)

Fixed submission:
S = input()
count = 1
strings = []
strings.append(S[0])
stack = ''
for s in S[1:]:
    stack += s
    if strings[-1] == stack:
        continue
    else:
        strings.append(stack)
        stack = ''
        count+=1    

print(count)

Buggy python submission (verdict: Runtime Error):
S = input()
count = 0
i = 0
while i < len(S)-2:
    if S[i] == S[i+1]:
        i +=3
        count += 2  
    else:
        i +=1
        count += 1
if S[i] == S[i+1]:
    count += 1
else:
    count += 2
print(count)

Fixed submission:
S = input()
count = 1
strings = []
strings.append(S[0])
stack = ''
for s in S[1:]:
    stack += s
    if strings[-1] == stack:
        continue
    else:
        strings.append(stack)
        stack = ''
        count+=1    

print(count)

Buggy python submission (verdict: Runtime Error):
S = input()
count = 0
i = 0
while i < len(S)-2:
    if S[i] == S[i+1]:
        print(S[i])
        print(S[i+1]+S[i+2])
        i +=3
        count += 2  
    else:
        print(S[i])
        i +=1
        count += 1
if S[i] == S[i+1]:
    count += 1
else:
    count += 2
print(count)

Fixed submission:
S = input()
count = 1
strings = []
strings.append(S[0])
stack = ''
for s in S[1:]:
    stack += s
    if strings[-1] == stack:
        continue
    else:
        strings.append(stack)
        stack = ''
        count+=1    

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = 0
i = 1
while N//i != 0:
    if N//(i*10) != 0:
        a += i*10 - i
        i = i*100
    else:
        a = N - i +1
print(a)

Fixed submission:
N = int(input())
a = 0
i = 1
while N//i != 0:
    if N//(i*10) != 0:
        a += i*10 - i
        i = i*100
    else:
        a += N - i +1
        i = i*100
print(a)
Buggy python submission (verdict: Runtime Error):
N = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(1,N+1):
    if p[i-1] != i:
        count += 1
    if count >2:
        print('NO')
        exit(0)
print('YES')

Fixed submission:
A, B = map(int,input().split())
K = (A+B) 
if K % 2 == 0:
    print(K//2)
else:
    print('IMPOSSIBLE')
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
all_remains = [0]*13
for digits, s in enumerate(S[::-1]):
    temp_remains = [0]*13     
    if s == '?':
        if digits == 0:
            for i in range(10):
                temp_remains[i % 13] += 1
        else:
            for i in range(10):
                r = i * (10**digits) % 13
                for j in range(13):
                    temp_remains[ (j + r) % 13] += all_remains[j]
    else:
        if digits == 0:
                temp_remains[int(s)] += 1
        else:
            n = int(s)*(10**digits) % 13
            for j in range(13):
                temp_remains[(j + n) % 13] += all_remains[j]
    all_remains = temp_remains
print(all_remains[5]%(10**9+7))


Fixed submission:
def main():
    M=10**9+7
    r=tuple(tuple((j-k)*9%13 for j in range(10))for k in range(13))
    d=[1]+[0]*12
    for c in input():
      if c>'9':
        d=[sum(d[j]for j in k)%M for k in r]
      else:
        d=[d[(int(c)-k)*9%13]for k in range(13)]
    print(d[5])
main()

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
all_remains = [0]*13
for digits, s in enumerate(S[::-1]):
    temp_remains = [0]*13     
    if s == '?':
        if digits == 0:
            for i in range(10):
                temp_remains[i % 13] += 1
        else:
            for i in range(10):
                for j in range(len(all_remains)):
                    temp_remains[ (j + i * (10**digits) % 13) % 13] += all_remains[j]
    else:
        if digits == 0:
                temp_remains[int(s)] += 1
        else:
            for j in range(len(all_remains)):
                temp_remains[(j + int(s)*(10**digits) % 13) % 13] += all_remains[j]
    all_remains = temp_remains
print(all_remains[5]%(10**9+7))

Fixed submission:
def main():
    M=10**9+7
    r=tuple(tuple((j-k)*9%13 for j in range(10))for k in range(13))
    d=[1]+[0]*12
    for c in input():
      if c>'9':
        d=[sum(d[j]for j in k)%M for k in r]
      else:
        d=[d[(int(c)-k)*9%13]for k in range(13)]
    print(d[5])
main()
Buggy python submission (verdict: Time Limit Exceeded):
import copy
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
B = sorted(A,reverse=True)
for a in A:
    C = copy.copy(B)
    C.remove(a)
    print(C[0])    

Fixed submission:
import copy
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
B = sorted(A,reverse=True)
for a in A:
    if a < B[0]:
        print(B[0])    
    else:
        print(B[1])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
for a in A:
    B = sorted(A,reverse=True)
    B.remove(a)
    print(B[0])

Fixed submission:
import copy
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
B = sorted(A,reverse=True)
for a in A:
    if a < B[0]:
        print(B[0])    
    else:
        print(B[1])
Buggy python submission (verdict: Runtime Error):
N,A,B=map((int),input(),split())
if N*A>B:
    print(B)
else:
    print(N*A)

Fixed submission:
N,A,B=map((int),input().split())
if N*A>B:
    print(B)
else:
    print(N*A)
Buggy python submission (verdict: Runtime Error):
L, R = map(int, input().split())
l_mod = L % 2019
r_mod = R % 2019
result = 2019
if l_mod > r_mod:
    print(0)
else:
    print((L_mod*(L_mod+1))%2019)

Fixed submission:
L, R = map(int, input().split())
l_mod = L % 2019
r_mod = R % 2019
if R >2019+L:
    print(0)
else:
    mod = (l_mod*(l_mod+1)) % 2019
    for i in range(l_mod,r_mod):
        for j in range(i+1,r_mod+1):
            if mod>(i*j)%2019:
                mod=(i*j)%2019
    print(mod)

Buggy python submission (verdict: Runtime Error):
L, R = map(int, input().split())
l_mod = L % 2019
r_mod = R % 2019
result = 2019
if l_mod > r_mod:
    print(0)
else:
    print(L_mod*(L_mod+1)%2019)

Fixed submission:
L, R = map(int, input().split())
l_mod = L % 2019
r_mod = R % 2019
if R >2019+L:
    print(0)
else:
    mod = (l_mod*(l_mod+1)) % 2019
    for i in range(l_mod,r_mod):
        for j in range(i+1,r_mod+1):
            if mod>(i*j)%2019:
                mod=(i*j)%2019
    print(mod)
Buggy python submission (verdict: Time Limit Exceeded):
K ,S = map(int,input().split())
count = 0
for x in range(S+1):
    if(x > K):
        continue
    for y in range(S+1):
        if(y > K):
            continue
        for z in range(S+1):
            if(z > K):
                continue
            if(x+y+z==S):
                count+=1
print(count)

Fixed submission:
K,S = map(int, input().split())
count = 0
for i in range(K,-1,-1):
    if i <= S:
        z = i
        sum_xy = S - i
        for j in range(K, -1,-1):
            if j <= sum_xy:
                y = j
                if sum_xy - j <= K:
                    count += 1
    else:
        continue
print(count)
Buggy python submission (verdict: Runtime Error):
S = input()
n = len(S)-1
total_num = 0
for i in range(2**n):
    num = '' 
    for j in range(n):
        if i & 2**j:
            num += S[j]
            total_num += int(num)
            num = ''
        else:
            num += S[j]
    num += S[j+1]
    total_num += int(num)
print(total_num)

Fixed submission:
S = input()
n = len(S)-1
total_num = 0
if n == 0:
    total_num = S[0]
else:
    for i in range(2**n):
        num = '' 
        for j in range(n):
            if i & 2**j:
                num += S[j]
                total_num += int(num)
                num = ''
            else:
                num += S[j]
        num += S[-1]
        total_num += int(num)
print(total_num)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n=int(input())

a=[]

a= list(map(int,input().split()))

ans=0
anssub=0
tmpsum=0
a=np.sort(a)
for i in range(n-1):
    if a[i]!=a[i-1]:
        for k in range(i+1,n):
            tmp=a[i]^a[k]
            tmpsum=tmp+tmpsum
            #print(a[i])
            #print(a[k])
            #print('\0')
            ans=(ans+tmp)%1000000007

    else:
        ans=(ans+tmpsum)%1000000007
    if a[i]!=a[i+1]:
        tmpsum=0
print(ans)



Fixed submission:
import numpy as np

n=int(input())



a= list(map(int,input().split()))
a=np.array(a,np.int64)


max=60
mod=10**9+7
ans=0
cnt1=0
cnt0=0


for i in range(max):
    new_a=(a>>i & 1)

    cnt1=np.count_nonzero(new_a)
    cnt0=n-cnt1
    ans=(ans+cnt1*cnt0*(2**i))%mod
    cnt1=0
    cnt0=0
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n=int(input())

a=[]

a= list(map(int,input().split()))

ans=0
for i in range(n-1):
    for k in range(i,n):
        tmp=a[i]^a[k]
        #print(tmp)
        ans=(ans+tmp)%1000000007

print(ans)
    


Fixed submission:
import numpy as np

n=int(input())



a= list(map(int,input().split()))
a=np.array(a,np.int64)


max=60
mod=10**9+7
ans=0
cnt1=0
cnt0=0


for i in range(max):
    new_a=(a>>i & 1)

    cnt1=np.count_nonzero(new_a)
    cnt0=n-cnt1
    ans=(ans+cnt1*cnt0*(2**i))%mod
    cnt1=0
    cnt0=0
print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np

n=int(input())

a=[]

for i in range(n):
    k=int(input())
    a.append(k)

ans=0
for i in range(n-1):
    for k in range(i,n):
        tmp=a[i]^a[k]
        #print(tmp)
        ans=(ans+tmp)%1000000007

print(ans)
    


Fixed submission:
import numpy as np

n=int(input())



a= list(map(int,input().split()))
a=np.array(a,np.int64)


max=60
mod=10**9+7
ans=0
cnt1=0
cnt0=0


for i in range(max):
    new_a=(a>>i & 1)

    cnt1=np.count_nonzero(new_a)
    cnt0=n-cnt1
    ans=(ans+cnt1*cnt0*(2**i))%mod
    cnt1=0
    cnt0=0
print(ans)
Buggy python submission (verdict: Runtime Error):

# 整数の入力
a = int(input())

# 文字列の入力
S = str(input())

chr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
SS = []

for k in range(len(S)):
    for j in range(len(chr)):
        if S[k] == chr[j]:
            if (j+a) >= 25:
                SS += chr[j+a-25]
            else:
                SS += chr[j+a]

SS = ''.join(SS)

print(SS)

Fixed submission:
# 整数の入力
a = int(input())

# 文字列の入力
S = str(input())

chr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
SS = []

for k in range(len(S)):
    for j in range(len(chr)):
        if S[k] == chr[j]:
            if (j+a) >= 25:
                SS += chr[j+a-26]
            else:
                SS += chr[j+a]

SS = ''.join(SS)

print(SS)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_s = list(map(int, input().split()))
sum_a_s = sum(a_s)

for i in range(n):
	tmp_sum = sum(a_s[:i])
	if tmp_sum >= sum_a_s - tmp_sum:
		break

tmp_res1 = abs(sum(a_s[:i - 1]) * 2 - sum_a_s)
tmp_res2 = abs(sum(a_s[:i]) * 2 - sum_a_s)
res = min(tmp_res1, tmp_res2)

print(res)


Fixed submission:
n = int(input())
a_s = list(map(int, input().split()))
sum_a_s = sum(a_s)

tmp_sum = 0
for i in range(n - 1):
	tmp_sum += a_s[i]
	if tmp_sum > sum_a_s - tmp_sum:
		break

tmp_res1 = abs(sum(a_s[:i]) * 2 - sum_a_s)
tmp_res2 = abs(sum(a_s[:i + 1]) * 2 - sum_a_s)
res = min(tmp_res1, tmp_res2)

print(res)

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

for i in range(n):
	if sum(a_s[:i]) >= sum(a_s[i:]):
		break

tmp_res1 = abs(sum(a_s[:i - 1]) - sum(a_s[i - 1:]))
tmp_res2 = abs(sum(a_s[:i]) - sum(a_s[i:]))
res = min(tmp_res1, tmp_res2)

print(res)


Fixed submission:
n = int(input())
a_s = list(map(int, input().split()))
sum_a_s = sum(a_s)

tmp_sum = 0
for i in range(n - 1):
	tmp_sum += a_s[i]
	if tmp_sum > sum_a_s - tmp_sum:
		break

tmp_res1 = abs(sum(a_s[:i]) * 2 - sum_a_s)
tmp_res2 = abs(sum(a_s[:i + 1]) * 2 - sum_a_s)
res = min(tmp_res1, tmp_res2)

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_s = list(map(int, input().split()))

for i in range(1, n + 1):
	print(a_s.index(i) + 1, end=" ")

Fixed submission:
n = int(input())
a_s = list(map(int, input().split()))

res = sorted(range(1, n + 1), key=lambda k:a_s[k - 1])
for r in res:
	print(r, end=" ")

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

res = [a_s.index(i) + 1 for i in range(1, n + 1)]
for r in res:
	print(r, end=" ")


Fixed submission:
n = int(input())
a_s = list(map(int, input().split()))

res = sorted(range(1, n + 1), key=lambda k:a_s[k - 1])
for r in res:
	print(r, end=" ")

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

res = [a_s.index(i) + 1 for i in range(1, n + 1)]
[print(r, end=" ") for r in res]


Fixed submission:
n = int(input())
a_s = list(map(int, input().split()))

res = sorted(range(1, n + 1), key=lambda k:a_s[k - 1])
for r in res:
	print(r, end=" ")
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import insort

n, m = map(int, input().split())
a_s = sorted(list(map(int, input().split())))

for i in range(m):
	new_amax = a_s[-1] // 2
	a_s = a_s[:-1]
	insort(a_s, new_amax)

res = sum(a_s)
print(res)

Fixed submission:
from math import ceil
from heapq import *

n, m = map(int, input().split())
a_s = [-int(a) for a in input().split()]
heapify(a_s)

for _ in range(m):
	amax = heappop(a_s)
	heappush(a_s, ceil(amax / 2))

res = sum([-heappop(a_s) for _ in range(n)])
print(res)

Buggy python submission (verdict: Runtime Error):
import sys

n, m = map(int, input().split())
a_s = sorted(list(map(int, input().split())))

if len(a_s) == 1:
	for i in range(m):
		a_s[0] = a_s[0] // 2
	print(a_s[0])
	sys.exit()

amax1, amax2 = a_s[-1], a_s[-2]

for i in range(m):
	a_s[a_s.index(amax1)] = amax1 // 2
	if amax1 // 2 < amax2:
		a_s = sorted(a_s)
		amax1, amax2 = a_s[-1], a_s[-2]

res = sum(a_s)
print(res)


Fixed submission:
from math import ceil
from heapq import *

n, m = map(int, input().split())
a_s = [-int(a) for a in input().split()]
heapify(a_s)

for _ in range(m):
	amax = heappop(a_s)
	heappush(a_s, ceil(amax / 2))

res = sum([-heappop(a_s) for _ in range(n)])
print(res)

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

for i in range(m):
	amax = max(a_s)
	a_s[a_s.index(amax)] = amax // 2

res = sum(a_s)
print(res)


Fixed submission:
from math import ceil
from heapq import *

n, m = map(int, input().split())
a_s = [-int(a) for a in input().split()]
heapify(a_s)

for _ in range(m):
	amax = heappop(a_s)
	heappush(a_s, ceil(amax / 2))

res = sum([-heappop(a_s) for _ in range(n)])
print(res)

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

for i in range(m):
	a_s = sorted(a_s)
	a_s[-1] = a_s[-1] // 2

res = sum(a_s)
print(res)


Fixed submission:
from math import ceil
from heapq import *

n, m = map(int, input().split())
a_s = [-int(a) for a in input().split()]
heapify(a_s)

for _ in range(m):
	amax = heappop(a_s)
	heappush(a_s, ceil(amax / 2))

res = sum([-heappop(a_s) for _ in range(n)])
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
print(sum(range(int(input()))))

Fixed submission:
n = int(input())
print((n * (n - 1)) // 2)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n = int(input())
ss = [input() for _ in range(n)]

sorted_ss = [''.join(sorted(s)) for s in ss]
sorted_set = set(sorted_ss)

cnt = 0
for s in sorted_set:
	c = sorted_ss.count(s)
	cnt += c * (c - 1) // 2

print(cnt)

Fixed submission:
from collections import Counter

n = int(input())
ss = [input() for _ in range(n)]

sorted_ss = [''.join(sorted(s)) for s in ss]
sorted_counter = Counter(sorted_ss)

cnt = sum([n * (n - 1) // 2 for n in sorted_counter.values()])
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ss = [input() for _ in range(n)]
sorted_ss = [''.join(sorted(s)) for s in ss]
sorted_set = set([s for s in sorted_ss])

cnt = 0
for s in sorted_set:
	c = sorted_ss.count(s)
	cnt += c * (c - 1) // 2

print(cnt)

Fixed submission:
from collections import Counter

n = int(input())
ss = [input() for _ in range(n)]

sorted_ss = [''.join(sorted(s)) for s in ss]
sorted_counter = Counter(sorted_ss)

cnt = sum([n * (n - 1) // 2 for n in sorted_counter.values()])
print(cnt)
Buggy python submission (verdict: Runtime Error):
from math import ceil
from bisect import bisect

n, a, b = map(int, input().split())
raw_hs = [int(input()) for _ in range(n)]
hs = sorted(raw_hs, reverse=True)
diff = a - b

c_min = 0
c_max = int(10e9)

while c_max - c_min > 1:
	c = (c_min + c_max) // 2
	tmp_hs = [h - c * b for h in hs]
	rem = sum([ceil(h / diff) for h in tmp_hs if h > 0])
	if rem > c:
		c_min = c
	else:
		c_max = c

print(c_max)


Fixed submission:
res = sum(map(int, input().split()))
if res >= 10:
	print("error")
else:
	print(res)
Buggy python submission (verdict: Runtime Error):
from itertools import permutations as perm

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

path = [[False] * n for _ in range(n)]
for i in range(n):
    path[i][i] = True

for _ in range(n):
    ai, bi = map(int, input().split())
    a, b = ai - 1, bi -1
    path[a][b] = True
    path[b][a] = True

ans = 0
for ps in perm(range(1, n)):
    fst = ps[0]
    if not path[0][fst]:
        continue
    check = [path[i][j] for (i, j) in zip(ps, ps[1:])]
    if all(check):
        ans += 1

print(ans)

Fixed submission:
from itertools import permutations as perm

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

path = [[False] * n for _ in range(n)]
for i in range(n):
    path[i][i] = True

for _ in range(m):
    ai, bi = map(int, input().split())
    a, b = ai - 1, bi - 1
    path[a][b] = True
    path[b][a] = True

ans = 0
for ps in perm(range(1, n)):
    fst = ps[0]
    if not path[0][fst]:
        continue
    check = [path[i][j] for (i, j) in zip(ps, ps[1:])]
    if all(check):
        ans += 1

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

s = set(a)
l = len(s)
l2 = 0 if len([a.count(x) for x in s]) % 2 else 1
print(l - l2)

Fixed submission:
x = int(input())

print("ABC" if x < 1200 else "ARC")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(x) for x in input().split()]

s = set(a)
l = len(s)
l2 = 0 if len([a.count(x) for x in s]) % 2 else 1
print(l - l2)

Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]

s = set(a)
l = len(s)
l2 = 0 if l % 2 else 1
print(l - l2)

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

s = set(a)
l = len(s)
l2 = 0 if len([a.count(x) for x in s]) % 2 else 1
print(l - l2)

Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]

s = set(a)
l = len(s)
l2 = 0 if l % 2 else 1
print(l - l2)

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

l = len(set(a))
l2 = 0 if len([a.count(x) for x in set(a)]) % 2 else 1
print(l - l2)

Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]

s = set(a)
l = len(s)
l2 = 0 if l % 2 else 1
print(l - l2)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product as prod

k, s = [int(x) for x in input().split()]

x = range(k + 1)
y = range(k + 1)
z = range(k + 1)
c = 0
for x, y, z in prod(x, y, z):
    if x + y + z == s:
        c += 1

print(c)

Fixed submission:
from itertools import product as prod

k, s = [int(x) for x in input().split()]

x = range(k + 1)
y = range(k + 1)
c = 0
for x, y in prod(x, y):
    if 0 <= s - x - y <= k:
        c += 1
print(c)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(x) for x in input().split()]

def is_satisfied(s):
    ln = len(s)
    check = [s.count(i) == 2 for i in range(ln - 1, 1, -2)]
    if ln % 2 == 0:
        check.append(s.count(1) == 2)
    else:
        check.append(s.count(0) == 1)

    return all(check)


ans = 2 ** (n // 2) if is_satisfied(a) else 0
print(ans)


Fixed submission:
a, op, b = input().split()
a = int(a)
b = int(b)
if op == "+":
    print(a + b)
elif op == "-":
    print(a - b)
Buggy python submission (verdict: Time Limit Exceeded):
n, x = map(int, input().split())
a = [int(i) for i in input().split()]
l = len(a)

ans = 0

for i in range(l-1):
    while a[i] + a[i+1] > x:
        a[i+1] -= 1
        ans += 1

print(ans)


Fixed submission:
n, x = map(int, input().split())
a = [int(i) for i in input().split()]
l = len(a)

ans = 0

for i in range(l-1):
    a_0 = a[i]
    a_1 = a[i+1]
    dif = x - a_0
    if a_1 > dif:
        ans += a_1 - dif
        if dif > 0:
            a[i+1] = dif
        else:
            a[i+1] = 0

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

t_num , a_num = map(int, input().split())

for t, a in [map(int, input().split()) for _ in range(n-1)]:
    pre_t_num, pre_a_num = t_num, a_num
    t_num, a_num = t, a
    n = 1
    while t_num < pre_t_num or a_num < pre_a_num:
        n = n + 1
        t_num, a_num = t * n, a * n

ans = t_num + a_num
print(ans)


Fixed submission:
n = int(input())

t_num , a_num = 1, 1

for t, a in [map(int, input().split()) for _ in range(n)]:
    pre_t_num, pre_a_num = t_num, a_num
    t_num, a_num = t, a
    if t_num < pre_t_num or a_num < pre_a_num:
        # m = m + 1
        t_k = (pre_t_num + t - 1) // t
        a_k = (pre_a_num + a - 1) // a
        m = max(t_k, a_k)
        t_num, a_num = t * m, a * m

ans = t_num + a_num
print()
print(ans)
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=input()
count=0
for i in range(1000):
  flag=False
  for j in range(a):
    if b[j]=='{0:03d}'.format(str(i))[0]:
      x=j
      flag=True
      break
  if flag:
    flag=False
  else:
    continue
  for k in range(x+1,a):
    if b[k]=='{0:03d}'.format(str(i))[1]:
      y=k
      flag=True
      break
  if flag:
    flag=False
  else:
    continue
  for l in range(y+1,a):
    if b[l]=='{0:03d}'.format(str(i))[1]:
      count+=1
      break
print(count)
      
  
    

Fixed submission:
a,b=map(int,input().split())
c,d=map(int,input().split())
if a+1==c:
  print(1)
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=input()
if a%2!=0:
  print("No")
else:
  a/=2
  c=b[:a]
  d=b[a:]
  if c==d:
    print("Yes")
  else:
    print("No")

Fixed submission:
a=int(input())
b=input()
if a%2!=0:
  print("No")
else:
  a//=2
  c=b[:a]
  d=b[a:]
  if c==d:
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
d=[]
e=[]
for i in range(c):
  d.append(int(input()))
for i in range(a):
  e.append(b-c)
for i in d:
  e[i+1]+-1
for i in e:
  if e<=0:
    print('No')
  else:
    print('Yes')
  

Fixed submission:
a,b,c=map(int,input().split())
d=[]
e=[]
for i in range(c):
  d.append(int(input()))
for i in range(a):
  e.append(b-c)
for i in d:
  e[i-1]+=1
for i in e:
  if i<=0:
    print('No')
  else:
    print('Yes')