Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
inp=list(map(int,input().split()))
S=inp[0]
B=inp[1]
R=inp[2]
x=S//(B+R)#brグループが何回
y=S%(B+R)

print(B*x+min(y,B))

Fixed submission:
inp=input()
if inp=='AAA'or inp=='BBB':
  print('No')
else:
  print('Yes')

Buggy python submission (verdict: Runtime Error):
inp=list(map(int,input().split()))
S=inp[0]
B=inp[1]
R=inp[2]
x=S//(B+R)#brグループが何回
y=S%(B+R)
print(B*x+y)

Fixed submission:
inp=input()
if inp=='AAA'or inp=='BBB':
  print('No')
else:
  print('Yes')

Buggy python submission (verdict: Runtime Error):
inp=list(map(int,input().split()))
S=inp[0]
B=inp[1]
R=inp[2]
x=S//(B+R)#brグループが何回
y=S//(B+R)
print(B*x+y)

Fixed submission:
inp=input()
if inp=='AAA'or inp=='BBB':
  print('No')
else:
  print('Yes')

Buggy python submission (verdict: Runtime Error):
inp=list(map(int,input().split()))
S=inp[0]
B=inp[1]
R=inp[2]
if B==0:
  print(0)
else:
  ans=B+(S-B-R)
  print(ans)

Fixed submission:
inp=input()
if inp=='AAA'or inp=='BBB':
  print('No')
else:
  print('Yes')
Buggy python submission (verdict: Runtime Error):
inp=list(map(int,input().split()))
S=inp[0]
B=inp[1]
R=inp[2]
x=S//(B+R)#brグループが何回
y=S//(B+R)
print(b*x+y)

Fixed submission:
inp=list(map(int,input().split()))
s=inp[0]
b=inp[1]
r=inp[2]
print(s//(b+r)*b+min(s%(b+r),b))

Buggy python submission (verdict: Runtime Error):
inp=list(map(int,input().split()))
S=inp[0]
B=inp[1]
R=inp[2]
ans=B+(S-B-A)
print(ans)

Fixed submission:
inp=list(map(int,input().split()))
s=inp[0]
b=inp[1]
r=inp[2]
print(s//(b+r)*b+min(s%(b+r),b))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
K,S=map(int,input().split())
lst=[num for num in range(K+1)]
ans=0
for i in itertools.product(lst,repeat=3):
  if sum(i)==S:
    ans+=1
print(ans)

Fixed submission:
import itertools
K,S=map(int,input().split())
ans=0
for i in range(K+1):
  for j in range(K+1):
    if i+j<=S and S-(i+j)<=K:
      #print(i,j)
      ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
K,S=map(int,input().split())
lst=[num for num in range(K+1)]
ans=0
for i in itertools.product(lst,repeat=3):
  if sum(i)==S:
    ans+=1
print(ans)

Fixed submission:
import itertools
K,S=map(int,input().split())
ans=0
for i in range(K+1):
  for j in range(K+1):
    if i+j<=S and S-(i+j)<=K:
      #print(i,j)
      ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
lst=list(map(int,input().split()))
if 5 in lst:
  lst.remove(5)
else:
    ans='No'
if 7 in lst:
  lst.remove(7)
else:
    ans='No'
if 7 in lst:
  ans='Yes'
print(ans)

Fixed submission:
lst=list(map(int,input().split()))
if 7 in lst:
  lst.remove(5)
else:
    ans='NO'
if 5 in lst:
  lst.remove(7)
else:
    ans='NO'
if 5 in lst:
  ans='YES'
print(ans)
Buggy python submission (verdict: Runtime Error):
S,W=int(input().split())
if W>=S:
    print("unsafe")
else:
    print("safe")

Fixed submission:
S,W=map(int,input().split())
if W>=S:
    print("unsafe")
else:
    print("safe")
Buggy python submission (verdict: Time Limit Exceeded):
K=int(input())
import math
count=0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            d=math.gcd(a,b)
            count+=math.gcd(c,d)
print(count)

Fixed submission:
K=int(input())
import math
count=0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            d=math.gcd(a,b)
            count+=math.gcd(c,d)
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
A=[]
R=abs(N-K)
for i in range(abs(N-K)+1):
    N=abs(N-K)
    R=min(R,N)
print(R)


Fixed submission:
N,K=map(int,input().split())
R=N%K
print(min(abs(K-R),abs(R)))

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
A=[]
for i in range(abs(N-K)+1):
    N=abs(N-K)
    A.append(N)
print(min(A))

Fixed submission:
N,K=map(int,input().split())
R=N%K
print(min(abs(K-R),abs(R)))
Buggy python submission (verdict: Runtime Error):
S=input()
if S[3] is S[4] and S[5] is S[6]:
    print("Yes")
else:
    print("No")

Fixed submission:
S=input()
if S[2] is S[3] and S[4] is S[5]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
import collections
import math

l = int(input())
st = []
for i in range(l):
    x = ''.join(sorted(input()))
    st.append(x)
c = collections.Counter(st)
cv = c.values()
sum = 0
for i in cv:
    if int(i) > 1:
        sum = sum + math.factorial(int(i))/2

print(math.floor(sum))

Fixed submission:
# coding: utf-8
import collections
import math

l = int(input())
st = []
for i in range(l):
    x = ''.join(sorted(input()))
    st.append(x)
c = collections.Counter(st)
cv = c.values()
sum = 0
for i in cv:
    if int(i) > 1:
        tm = 0
        for j in range(int(i)-1):
            tm = tm + int(i)-1-j
        sum = sum + tm

print(math.floor(sum))
Buggy python submission (verdict: Runtime Error):
# coding: utf-8

str = input()

if str =='A' :
    str = 'T'
    break
elif str == 'T' :
    str = 'A'
    break
elif str == 'C':
    str = 'G'
elif str == 'G':
    str = 'C'

print(str)

Fixed submission:
# coding: utf-8

str = input()

if str =='A' :
    str = 'T'
elif str == 'T' :
    str = 'A'
elif str == 'C':
    str = 'G'
elif str == 'G':
    str = 'C'

print(str)
Buggy python submission (verdict: Runtime Error):
number = input()
number_list = list(number)
A = int(number_list[0])
B = int(number_list[2])
K = int(number_list[4])

while K > 0:
    if A % 2 == 0:
        A = A
    else:
        A = A - 1
    A = A / 2
    B = B + A
    K = K - 1
    if K > 0:
        if B % 2 == 0:
            B = B
        else:
            B = B - 1
        B = B / 2
        A = A + B
        K = K - 1
print(str(int(A)) + ' ' + str(int(B)))

Fixed submission:
number = input().strip().split(' ')
number_list = list(map(int,number))
A = number_list[0]
B = number_list[1]
K = number_list[2]

while K > 0:
    if A % 2 == 0:
        A = A
    else:
        A = A - 1
    A = A / 2
    B = B + A
    K = K - 1
    if K > 0:
        if B % 2 == 0:
            B = B
        else:
            B = B - 1
        B = B / 2
        A = A + B
        K = K - 1
print(str(int(A)) + ' ' + str(int(B)))
Buggy python submission (verdict: Runtime Error):
# cording:utf-8
n,t = (int(x) for x in input().split())
cost_list = list()
time_list = list()
while n >= 1:
    c,tn = (int(x) for x in input().split())
    if tn >= t:
        cost_list.append(c)
        time_list.append(tn)
        n = n - 1
    else:
        n = n - 1
best_time = min(time_list)
if best_time <= t:
    best_time_number = time_list.index(best_time)
    print(cost_list[best_time_number])
else:
    print('TLE')

Fixed submission:
# cording:utf-8
n,t_limit = (int(x) for x in input().split())
cost_list = list()
time_list = list()
while n >= 1:
    c,tn = (int(x) for x in input().split())
    if tn <= t_limit:
        cost_list.append(c)
        time_list.append(tn)
        n = n - 1
    else:
        n = n - 1
if not time_list:
    print('TLE')
else:
    best_cost = min(cost_list)
    print(best_cost)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = map(int, input().split())
i = N

while i % B != 0:
  i = i - 1
  
i = i - 1
if i < 0:
  ans = (A * N) // B - A * (N // B)
else:
  ans = (A * i) // B - A * (i // B)
  
print(ans)

Fixed submission:
A, B, N = map(int, input().split())
i = (N // B) * B
  
i = i - 1
if i < 0:
  ans = (A * N) // B - A * (N // B)
else:
  ans = (A * i) // B - A * (i // B)
  
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = map(int, input().split())
x = []
i = N

while i % B != 0:
  x.append(i % B)
  i = i - 1
  
i = i - 1
if i < 0:
  ans = (A * x[0]) // B - A * (x[0] // B)
else:
  ans = (A * i) // B - A * (i // B)
  
print(ans)

Fixed submission:
A, B, N = map(int, input().split())
i = (N // B) * B
  
i = i - 1
if i < 0:
  ans = (A * N) // B - A * (N // B)
else:
  ans = (A * i) // B - A * (i // B)
  
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from math import gcd

K = int(input())
ans = 0

for i in range(K):
  for j in range(K):
    for k in range(K):
      ans += gcd(gcd(i + 1, j + 1), k + 1)
      
print(ans)

Fixed submission:
from math import gcd

K = int(input())
ans = 0

for i in range(1, K + 1):
  for j in range(1, K + 1):
    for k in range(1, K + 1):
      ans += gcd(gcd(i, j), k)
      
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
c = [A.count(i + 1) for i in range(N)]
ans = [c[i] * (c[i] - 1) // 2 for i in range(N)]
s = sum(ans)

for val in A:
  m = c[val - 1] - 1
  print(s - m)

Fixed submission:
N, M = map(int, input().split())
NM = N + M
print(NM * (NM - 1) // 2 - N * M)
Buggy python submission (verdict: Runtime Error):
H, N = map(int, input().split())
A = map(int, input().split())
sum = 0

for val in A:
	sum = sum + val

if sum >= H 
	print("Yes")
  
print("No")


Fixed submission:
H, A = map(int, input().split())
i = 0

while H > 0:
	H = H - A
	i = i + 1

print(i)
Buggy python submission (verdict: Runtime Error):
H, N = map(int, input().split())
A = list(map(int, input().split()))
sum = 0

for val in A:
	sum = sum + val

if sum >= H 
	print("Yes")
  
print("No")


Fixed submission:
H, N = map(int, input().split())
A = map(int, input().split())
sum = 0

for val in A:
	sum = sum + val

if sum >= H:
	print("Yes")
else:  
	print("No")

Buggy python submission (verdict: Runtime Error):
H, N = map(int, input().split())
A = map(int, input().split())
sum = 0

for val in A:
	sum = sum + val

if sum >= H 
	print("Yes")
  
print("No")


Fixed submission:
H, N = map(int, input().split())
A = map(int, input().split())
sum = 0

for val in A:
	sum = sum + val

if sum >= H:
	print("Yes")
else:  
	print("No")

Buggy python submission (verdict: Runtime Error):
H, N = map(int, input().split())
A = list(map(int, input().split()))
sum = 0

for val in A
	sum = sum + val

if sum >= H 
	print("Yes")
  
print("No")


Fixed submission:
H, N = map(int, input().split())
A = map(int, input().split())
sum = 0

for val in A:
	sum = sum + val

if sum >= H:
	print("Yes")
else:  
	print("No")

Buggy python submission (verdict: Runtime Error):
H, N = map(int, input().split())
A = map(int, input().split())
sum = 0

for val in A
	sum = sum + val

if sum >= H 
	print("Yes")
  
print("No")

Fixed submission:
H, N = map(int, input().split())
A = map(int, input().split())
sum = 0

for val in A:
	sum = sum + val

if sum >= H:
	print("Yes")
else:  
	print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
list_A = list(map(int,input().split()))

for i in range(N):
    count = 0
    count = list_A.count(i+1)
    print(count)

Fixed submission:
N = int(input())
list_A = list(map(int,input().split()))
B = [0]*N

for a in list_A:
    B[a-1] += 1

for i in range(N):
    print(B[i])
Buggy python submission (verdict: Runtime Error):
import math

a,b=(int(x) for x in input().split())

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))

Fixed submission:
import fractions
a, b = map(int, input().split())
print(a * b // fractions.gcd(a, b))
Buggy python submission (verdict: Runtime Error):
s=input()
count=0
i=0
while i<=range(len(s) // 2):
	if s[i]!=s[-(i+1)]:
		count+=1
    i+=1
print(count)

Fixed submission:
s=input()
count=0

for i in range(len(s) // 2):
	if s[i]!=s[-(i+1)]:
		count+=1
print(count)

Buggy python submission (verdict: Runtime Error):
s=input()
i=0
count=0

while i<range(len(s)//2):
	if s[i]!=s[-(i+1)]:
		count+=1
	i+=1

print(count)

Fixed submission:
s=input()
count=0

for i in range(len(s) // 2):
	if s[i]!=s[-(i+1)]:
		count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
a,b=(int(x) for x in input().split())

if a<10 and b<10:
	print(a*b)
else::
	print("-1")

Fixed submission:
a,b=(int(x) for x in input().split())

if a<10 and b<10:
	print(a*b)
else:
	print("-1")
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

import math
p = [a, b, c, d, e]
pa = [a%10, b%10, c%10, d%10, e%10]
ans = math.ceil(a/10)*10 + math.ceil(b/10)*10 + math.ceil(c/10)*10 + math.ceil(d/10)*10 + math.ceil(e/10)*10 - (10 - pa[pa.index(min([i for i in pa if i != 0]))])
print(ans)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

import math
p = [a, b, c, d, e]
pa = []
for i in range(len(p)):
    if p[i]%10 == 0:
        pa.append(0)
    else:
        pa.append(10 - p[i]%10)

ans = math.ceil(a/10)*10 + math.ceil(b/10)*10 + math.ceil(c/10)*10 + math.ceil(d/10)*10 + math.ceil(e/10)*10 - max(pa)
print(ans)
Buggy python submission (verdict: Runtime Error):
p = [a, b, c, d, e]
n//min(p)+5

Fixed submission:
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

p = [a, b, c, d, e]
if n%min(p) != 0:
    print(n//min(p)+5)
else:
    print(n//min(p)+4)
Buggy python submission (verdict: Runtime Error):
s = input()

l = [0]*len(s)
for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or  s[i] == 'T':
        l[i]=1
        
a = []
ans=0
for k in l:
    if k==1:
        ans += k
    else:
        a.append(ans)
        ans=0
        
print(max(a))

Fixed submission:
s = input()
import re
l = re.split('B|D|E|F|H|I|J|K|L|M|N|O|P|Q|R|S|U|V|W|X|Y|Z', s)
print(max([len(i) for i in l]))
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
l = []
r = []
ans = []
for i in range(q):
    lq, rq = map(int, input().split())
    print(s[lq-1:rq].count('AC'))

Fixed submission:
N,Q=map(int,input().split())
S=input()
count=[0]*N
for i in range(1,N):
    count[i]+=count[i-1]
    if S[i-1:i+1]=="AC":count[i]+=1
for i in range(Q):
    l,r=map(int,input().split())
    print(count[r-1]-count[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
l = []
r = []
ans = []
for _ in range(q):
    lq, rq = map(int, input().split())
    ans.append(s[lq-1:rq].count('AC'))
     
for i in range(q):
    print(ans[i])

Fixed submission:
N,Q=map(int,input().split())
S=input()
count=[0]*N
for i in range(1,N):
    count[i]+=count[i-1]
    if S[i-1:i+1]=="AC":count[i]+=1
for i in range(Q):
    l,r=map(int,input().split())
    print(count[r-1]-count[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
l = []
r = []
for _ in range(q):
    lq, rq = map(int, input().split())
    l.append(lq)
    r.append(rq)
    
for i in range(q):
    print(s[l[i]-1:r[i]].count('AC'))

Fixed submission:
N,Q=map(int,input().split())
S=input()
count=[0]*N
for i in range(1,N):
    count[i]+=count[i-1]
    if S[i-1:i+1]=="AC":count[i]+=1
for i in range(Q):
    l,r=map(int,input().split())
    print(count[r-1]-count[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
count = 0
while len(set(s)) == 2:
    for i in range(len(s)):
        if (s[i] == '0' and s[i+1]== '1') or (s[i] == '1' and s[i+1]== '0'):
            s.pop(i)
            s.pop(i)
            count += 2
            break
print(count)

Fixed submission:
s = input()
print(min(s.count('1'), s.count('0'))*2)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
x = sorted(list(map(int, input().split())))
d = []
for i in range(m-1):
    d.append(x[i+1] - x[i])
    
ans = 0
if n>=m:
    ans = 1
else:
    for i in range(n):
        if i == 0:
            ans += x[:d.index(sorted(d)[::-1][i])+1][-1] - x[:d.index(sorted(d)[::-1][i])+1][0]
        elif i == n-1:
            ans += x[d.index(sorted(d)[::-1][i-1])+1:][-1] - x[d.index(sorted(d)[::-1][i-1])+1:][0]
        else:
            ans += x[d.index(sorted(d)[::-1][i-1])+1:d.index(sorted(d)[::-1][i])+1][-1] - x[d.index(sorted(d)[::-1][i-1])+1:d.index(sorted(d)[::-1][i])+1][0]

print(ans)

Fixed submission:
n, m = map(int, input().split())
x = sorted(list(map(int, input().split())))
d = []
if n>=m or m==1:
    print(0)
elif n<m:
    for i in range(m-1):
        d.append(x[i+1] - x[i])
    print(sum(sorted(d)[:m-n]))
Buggy python submission (verdict: Runtime Error):
n = int(input())

import math
def bank2(n):
    ans = 1
    list_six = [6**i for i in range(math.floor(math.log(n, 6)+1))]
    list_nine = [9**i for i in range(math.floor(math.log(n, 9)+1))]
    
    if n in list_six or n in list_nine:
        pass
    elif n == 12 or n == 13 or n == 14:
        ans += bank(n-6)
    elif n > 1:
        ans += min(bank(n - list_six[-1]), bank(n - list_nine[-1]))
        
    return ans

print(bank2(n))

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

ans = []
for i in range(n+1):
    cnt6 = i
    cnt9 = n - i
    ans6 = 0
    ans9 = 0
    
    while cnt6 > 0:
        sho = 6**math.floor(math.log(cnt6, 6))
        ans6 += cnt6//sho
        cnt6= cnt6%sho
        
    while cnt9 > 0:
        if cnt9 != 59049:
            sho2 = 9**math.floor(math.log(cnt9, 9))
        else:
            sho2=59049
        ans9 += cnt9//sho2
        cnt9 = cnt9%sho2
        
    ans.append(ans6+ans9)
    sho, sho2 = 0, 0
        
print(min(ans))

Buggy python submission (verdict: Runtime Error):
n = int(input())
import math
def bank(n):
    ans = 1
    list_six = [6**i for i in range(math.floor(math.log(n, 6)+1))]
    list_nine = [9**i for i in range(math.floor(math.log(n, 9)+1))]
    
    if n == 6 or n== 9:
        pass
    elif n == 12 or n == 13 or n == 14:
        ans += bank(n-6)
    elif n > 1:
        ans += bank(n - max(list_six[-1], list_nine[-1]))
        
    return ans
  
print(bank(n))

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

ans = []
for i in range(n+1):
    cnt6 = i
    cnt9 = n - i
    ans6 = 0
    ans9 = 0
    
    while cnt6 > 0:
        sho = 6**math.floor(math.log(cnt6, 6))
        ans6 += cnt6//sho
        cnt6= cnt6%sho
        
    while cnt9 > 0:
        if cnt9 != 59049:
            sho2 = 9**math.floor(math.log(cnt9, 9))
        else:
            sho2=59049
        ans9 += cnt9//sho2
        cnt9 = cnt9%sho2
        
    ans.append(ans6+ans9)
    sho, sho2 = 0, 0
        
print(min(ans))
Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
l = list(range(a, b+1))
for i in sorted(list(set(l[:k]) | set(l[-k:]))):
    print(i)

Fixed submission:
a, b, k = map(int, input().split())
l = []
for i in range(k):
    if a+i <= b-i:
        l.append(a+i)
        l.append(b-i)

List = sorted(set(l))
for i in range(len(List)):
    print(List[i])

Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
l = list(range(a, b+1))
for i in sorted(list(set(l[:k] + l[-k:]))):
    print(i)

Fixed submission:
a, b, k = map(int, input().split())
l = []
for i in range(k):
    if a+i <= b-i:
        l.append(a+i)
        l.append(b-i)

List = sorted(set(l))
for i in range(len(List)):
    print(List[i])

Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
l = list(range(a, b+1))
if k != 0:
    for i in range(len(list(set(l[:k] + l[-k:])))):
        print(sorted(list(set(l[:k] + l[-k:])))[i])
else:
    print()

Fixed submission:
a, b, k = map(int, input().split())
l = []
for i in range(k):
    if a+i <= b-i:
        l.append(a+i)
        l.append(b-i)

List = sorted(set(l))
for i in range(len(List)):
    print(List[i])

Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
l = list(range(a, b+1))
for i in range(len(list(set(l[:k] + l[-k:])))):
    print(sorted(list(set(l[:k] + l[-k:])))[i])

Fixed submission:
a, b, k = map(int, input().split())
l = []
for i in range(k):
    if a+i <= b-i:
        l.append(a+i)
        l.append(b-i)

List = sorted(set(l))
for i in range(len(List)):
    print(List[i])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

for i in range(n):
    b = [0] + a[:i] + a[i+1:] + [0]
    d = 0
    for j in range(len(b)-1):
        d += abs(b[j]-b[j+1])
    print(d)

Fixed submission:
n = int(input())
a = [0] + list(map(int, input().split())) + [0]
cost = 0
for i in range(n+1):
    cost += abs(a[i] - a[i+1])
    
for j in range(1, n+1):
    if a[j-1] <= a[j] <= a[j+1] or a[j-1] >= a[j] >= a[j+1]:
        print(cost)
    else:
        print(cost - min(abs(a[j] - a[j-1]), abs(a[j] - a[j+1]))*2)

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

for i in range(n):
    b = [0] + a[:i] + a[i+1:] + [0]
    ans = 0
    for j in range(len(b)-1):
        ans += abs(b[j] - b[j+1])
    print(ans)

Fixed submission:
n = int(input())
a = [0] + list(map(int, input().split())) + [0]
cost = 0
for i in range(n+1):
    cost += abs(a[i] - a[i+1])
    
for j in range(1, n+1):
    if a[j-1] <= a[j] <= a[j+1] or a[j-1] >= a[j] >= a[j+1]:
        print(cost)
    else:
        print(cost - min(abs(a[j] - a[j-1]), abs(a[j] - a[j+1]))*2)
Buggy python submission (verdict: Runtime Error):
n = int(input())
sn = [input() for _ in range(n)]
m = int(input())
sm = [input() for _ in range(m)]

List = []
for i in range(len(list(set(n)))):
    List.append(n.count(list(set(n))[i]) - m.count(list(set(n))[i]))
    
print(max(List))

Fixed submission:
n = int(input())
sn = [input() for _ in range(n)]
m = int(input())
sm = [input() for _ in range(m)]

List = []
for i in range(len(list(set(sn)))):
    List.append(sn.count(list(set(sn))[i]) - sm.count(list(set(sn))[i]))
    
print(max(max(List), 0))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
A = []
A.append([0 for _ in range(m+2)])
for _ in range(n):
    A.append([0] + [1 for _ in range(m)] + [0])
A.append([0 for _ in range(m+2)])

for i in range(1, n+1):
    for j in range(1, m+1):
        A[i][j-1] *= -1
        A[i][j] *= -1
        A[i][j+1] *= -1
        A[i+1][j-1] *= -1
        A[i+1][j] *= -1
        A[i+1][j+1] *= -1
        A[i-1][j-1] *= -1
        A[i-1][j] *= -1
        A[i-1][j+1] *= -1
        
import itertools
print(list(itertools.chain.from_iterable(A)).count(-1))

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

import itertools
print(abs(m*n - ((n-1)*2 + (m-1)*2)))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
    b.append(a[i])
    b = b[::-1]
print(*b)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
if len(a)%2 == 0:
    b = a[::-2]+a[::2]
else:
    b = a[::-2]+a[1::2]
    
print(*b)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a==b=="H" or a==b=="D":
    print("H")
else:
    print("D")

Fixed submission:
a, b = input().split()
if a == b:
    print('H')
else:
    print('D')
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
ans = 0
for i in range(k+1):
    for j in range(k+1):
        for m in range(k+1):
            if i+j+m==s:
                ans += 1
                
print(ans)

Fixed submission:
k, s = map(int, input().split())
ans = 0
for i in range(k+1):
    for j in range(k+1):
        if s-i-j <= k and 0<=s-i-j:
            ans += 1
        
print(ans)
Buggy python submission (verdict: Runtime Error):
if len(a)%2==1:
    tmp = [0]
    for i in range((len(a)-1)//2):
        tmp.append((i+1)*2)
        tmp.append((i+1)*2)
    if a == tmp:
        ans = (2**((len(a)-1)//2))%(10**9+7)
    else:
        ans = 0
else:
    tmp = []
    for i in range(len(a)//2):
        tmp.append(2*i+1)
        tmp.append(2*i+1)
    if a == tmp:
        ans = (2**(len(a)//2))%(10**9+7)
    else:
        ans = 0
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 0
if n%2==1:
    dummy = [0]
    for i in range(1, 1+(len(a)-1)//2):
        dummy.append(2*i)
        dummy.append(2*i)
    if sorted(a) == dummy:
        ans = 2**((len(a)-1)//2)
else:
    dummy = []
    for i in range(1,  1+(len(a))//2):
        dummy.append(2*i - 1)
        dummy.append(2*i - 1)
    if sorted(a) == dummy:
        ans = 2**((len(a))//2)
print(ans%(10**9 + 7))