Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().split())
c = a * b
if c % 2:
    print("Odd")
else:
    print("Even")


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
cnt = 0

while True:
    for num, a in enumerate(A):
        if a % 2:
            print(cnt)
            break
        else:
            A[num] = a / 2
    if a % 2:
        break
    cnt += 1
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
color = [0] * n 
path = [[] for _ in range(m)]

for i in range(m):
    a, b = map(int, input().split())
    path[a-1].append(b)
    path[b-1].append(a)

print(path)
def rec(c, p, crnt, d):
    d += 1
    if c[crnt] == 1:
        if len(list(filter(lambda x: x == 1, c))) == m and d == m+1:
            return 1
        else:
            return 0
    elif c[crnt] > 1:
        return 0
    else:
        c[crnt] += 1
        sm = 0
        for i in p[crnt]:
            sm += rec(c, p, i-1, d)
        return sm

print(rec(color, path, 0, 0))


Fixed submission:
from itertools import permutations
n, m = map(int, input().split())
v = [set(map(int, input().split())) for _ in range(m)]

ans = 0
x = [i for i in range(2, n+1)]
cand = permutations(x)
for i in cand:
    crnt = 1
    for nxt in i:
        if set([crnt, nxt]) in v:
            crnt = nxt
        else:
            break
    else:
        ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
color = [0] * n 
path = [[] for _ in range(m)]

for i in range(m):
    a, b = map(int, input().split())
    path[a-1].append(b)
    path[b-1].append(a)

def rec(c, p, crnt, d):
    d += 1
    if c[crnt]:
        if len(list(filter(lambda x: x == 1, c))) == m and d == m+1:
            return 1
        else:
            return 0
    else:
        c[crnt] = 1
        sm = 0
        for i in p[crnt]:
            sm += rec(c, p, i-1, d)
        return sm

print(rec(color, path, 0, 0))


Fixed submission:
from itertools import permutations
n, m = map(int, input().split())
v = [set(map(int, input().split())) for _ in range(m)]

ans = 0
x = [i for i in range(2, n+1)]
cand = permutations(x)
for i in cand:
    crnt = 1
    for nxt in i:
        if set([crnt, nxt]) in v:
            crnt = nxt
        else:
            break
    else:
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
n = int(input())
A = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans *= A[i]
if(ans > 1000000000000000000):
    print("-1")
else:
    print(ans)

Fixed submission:
# coding: utf-8
n = int(input())
A = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans *= A[i]
    if(ans > 1000000000000000000):
        if 0 in A:
            print("0")
            quit()
        else:
            print("-1")
            quit()
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n = int(input())
S = deque([])
for i in range(n):
    s = input()
    if s not in S:
        S.append(s)
print(len(S))

Fixed submission:
# coding: utf-8
n = int(input())
S = set([])
for i in range(n):
    s = input()
    S.add(s)
print(len(S))
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

n, k = map(int, input().split())
min = n

while(1):
    n = abs(n-k)
    if n >= min:
        break
    else:
        min = n

print(min)

Fixed submission:
# coding: utf-8

n, k = map(int, input().split())
t = n % k
if t > k-t:
    print(k-t)
else:
    print(t)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

n, k = map(int, input().split())
min = n

while(1):
    n = abs(n-k)
    if n >= min:
        break
    else:
        min = n

print(min)

Fixed submission:
# coding: utf-8

n, k = map(int, input().split())
t = n % k
if t > k-t:
    print(k-t)
else:
    print(t)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

k = int(input())
queue = [1,2,3,4,5,6,7,8,9]

for i in range(k):
    a = queue.pop(0)
    if a % 10 != 0:
        queue.append(10 * a + (a%10) - 1)
    queue.append(10 * a + (a%10))
    if a % 10 != 9:
        queue.append(10 * a + (a%10) + 1)

print(a)

Fixed submission:
# coding: utf-8
from collections import deque

k = int(input())
queue = deque([1,2,3,4,5,6,7,8,9])

for i in range(k):
    a = queue.popleft()
    if a % 10 != 0:
        queue.append(10 * a + (a%10) - 1)
    queue.append(10 * a + (a%10))
    if a % 10 != 9:
        queue.append(10 * a + (a%10) + 1)

print(a)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
import itertools

k, n = map(int, input().split())
a = list(map(int, input().split()))
ans = []

for list in itertools.permutations(range(n)):
    count = 0
    for i in range(n-1):
        t1 = a[list[i+1]] - a[list[i]]
        t2 = a[list[i+1]] + 20 - a[list[i]]
        if t1 > k/2:
            count += k - t1
        elif t1 > 0:
            count += t1
        elif t2 > k/2:
            count += k - t2
        else:
            count += t2
    ans.append(count)
print(min(ans))

Fixed submission:
# coding: utf-8
k, n = map(int, input().split())
a = list(map(int, input().split()))
max = 0

for i in range(n-1):
    l = a[i+1] - a[i]
    if l > max:
        max = l
l = a[0] - a[n-1] + k
if l > max:
    max = l
print(k - max)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
import itertools

k, n = map(int, input().split())
a = list(map(int, input().split()))
ans = []

for list in itertools.permutations(range(n)):
    count = 0
    for i in range(n-1):
        t1 = a[list[i+1]] - a[list[i]]
        t2 = a[list[i+1]] + 20 - a[list[i]]
        if t1 > k/2:
            count += k - t1
        elif t1 > 0:
            count += t1
        elif t2 > k/2:
            count += k - t2
        else:
            count += t2
    ans.append(count)
print(min(ans))

Fixed submission:
# coding: utf-8
k, n = map(int, input().split())
a = list(map(int, input().split()))
max = 0

for i in range(n-1):
    l = a[i+1] - a[i]
    if l > max:
        max = l
l = a[0] - a[n-1] + k
if l > max:
    max = l
print(k - max)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
N, X, Y = map(int, input().split())
list = []
for i in range(1,N):
    for j in range(i+1,N+1):
        list.append(min(j-i, abs(X-i)+1+abs(Y-j)))
for k in range(1,N):
    print(list.count(k))

Fixed submission:
# coding: utf-8
N, X, Y = map(int, input().split())
ans = [0]*N
for i in range(1,N):
    for j in range(i+1,N+1):
        l = min(j-i, abs(X-i)+1+abs(Y-j))
        ans[l] += 1
for k in range(1,N):
    print(ans[k])

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
N, X, Y = map(int, input().split())
list = []
for i in range(1,N):
    for j in range(i+1,N+1):
        list.append(min(j-i, abs(X-i)+1+abs(Y-j)))
for k in range(1,N):
    print(list.count(k))

Fixed submission:
# coding: utf-8
N, X, Y = map(int, input().split())
ans = [0]*N
for i in range(1,N):
    for j in range(i+1,N+1):
        l = min(j-i, abs(X-i)+1+abs(Y-j))
        ans[l] += 1
for k in range(1,N):
    print(ans[k])

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
N, X, Y = map(int, input().split())
list = []
for i in range(1,N):
    for j in range(2,N+1):
        list.append(min(j-i, abs(X-i)+1+abs(Y-j)))
for k in range(1,N):
    print(list.count(k))

Fixed submission:
# coding: utf-8
N, X, Y = map(int, input().split())
ans = [0]*N
for i in range(1,N):
    for j in range(i+1,N+1):
        l = min(j-i, abs(X-i)+1+abs(Y-j))
        ans[l] += 1
for k in range(1,N):
    print(ans[k])
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
n = int(input())
A = list(map(int, input().split()))
X = [0]*n
for a in A:
    X[a] += 1
s = 0
for x in X:
    s += x*(x-1)//2
for a in A:
    print(s-X[a]+1)

Fixed submission:
# coding: utf-8
n = int(input())
A = list(map(int, input().split()))
X = [0]*(n+1)
for a in A:
    X[a] += 1
s = 0
for x in X:
    s += x*(x-1)//2
for a in A:
    print(s-X[a]+1)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
n = int(input())
a = list(map(int, input().split()))
num = 0
for i in range(n):
    b = a.count(i)
    num += int(b*(b-1)/2)
for k in range(1,n+1):
    print(num - a.count(a[k-1]) + 1)

Fixed submission:
# coding: utf-8
n = int(input())
A = list(map(int, input().split()))
X = [0]*(n+1)
for a in A:
    X[a] += 1
s = 0
for x in X:
    s += x*(x-1)//2
for a in A:
    print(s-X[a]+1)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
from collections import deque
n = int(input())
a = deque(list(map(int, input().split())))
for i in range(n):
    num = 0
    b = a.popleft()
    for j in range(n):
        c = a.count(j)
        num += int(c*(c-1)/2)
    print(num)
    a.append(b)

Fixed submission:
# coding: utf-8
n = int(input())
A = list(map(int, input().split()))
X = [0]*(n+1)
for a in A:
    X[a] += 1
s = 0
for x in X:
    s += x*(x-1)//2
for a in A:
    print(s-X[a]+1)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    num = 0
    b = a.pop(0)
    for j in range(n):
        c = a.count(j)
        num += int(c*(c-1)/2)
    print(num)
    a.append(b)

Fixed submission:
# coding: utf-8
n = int(input())
A = list(map(int, input().split()))
X = [0]*(n+1)
for a in A:
    X[a] += 1
s = 0
for x in X:
    s += x*(x-1)//2
for a in A:
    print(s-X[a]+1)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
from collections import deque
def main():
    s = deque(input())
    q = int(input())
    top = True
    for i in range(q):
        query = list(map(str, input().split()))
        if query[0] == "1":
            top = not top
        else:
            if (query[1]=="1" and top==True) or (query[1]=="2" and top==False):
                s.appendleft(query[2])
            else:
                s.append(query[2])
    if top == False:
        for i in range(len(s)):
            print(s[len(s)-1-i],end="")
    else:
        for c in s:
            print(c,end="")
            
if __name__ == '__main__':
    main()

Fixed submission:
# coding: utf-8
from collections import deque
def main():
    s = deque(input())
    q = int(input())
    top = True
    for i in range(q):
        query = list(map(str, input().split()))
        if query[0] == "1":
            top = not top
        else:
            if (query[1]=="1" and top==True) or (query[1]=="2" and top==False):
                s.appendleft(query[2])
            else:
                s.append(query[2])
    if top == False:
        for i in range(len(s)):
            print(s[len(s)-1-i],end="")
    else:
        for c in s:
            print(c,end="")
            
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
#mitsui d
import sys
import math
import collections
#sys.setrecursionlimit(100000)

n=int(input())

s=input()
#tmp = input().split()
#s = list(map(lambda a: int(a), tmp))

ans=0

for i in range(0,10):
	for j in range(0,10):
		for k in range(0,10):
			flg=0
			for index in range(0,n):
				if(flg==0)and(s[index]==str(i)):
					flg+=1
				elif(flg==1)and(s[index]==str(j)):
					flg+=1
				elif(flg==2)and(s[index]==str(k)):
					flg+=1
					break
			if(flg==3):
				tst=str(i)+str(j)+str(k)
#				print(tst)
				ans+=1
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
#mitsui d
import sys
import math
import collections
#sys.setrecursionlimit(100000)

n=int(input())

s=input()
#tmp = input().split()
#s = list(map(lambda a: int(a), tmp))

sfirst=[]
slast=[]
for i in range(0,10):
	sfirst.append(n)
	slast.append(0)
for i in range(0,n):
	if(sfirst[int(s[i])]>i):
		sfirst[int(s[i])]=i
	if(slast[int(s[i])]<i):
		slast[int(s[i])]=i
#print(s)
#print(sfirst)
#print(slast)

ans=0

for i in range(0,10):
	for j in range(0,10):
		for k in range(0,10):
			flg=0
			for index in range(sfirst[i]+1,slast[k]):
				if(flg==0)and(s[index]==str(j)):
					flg+=1
					ans+=1
					break
print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
#DISCO C
import sys
import math
import collections
#sys.setrecursionlimit(100000)

#n=int(input())

tmp = input().split()
h,w,k = list(map(lambda a: int(a), tmp))

list = [[0 for i in range(w+1)] for j in range(h)]
for i in range(0,h):
	tmp = input()
	for j in range(0,w):
		if(tmp[j]=='#'):
			list[i][j]+=1
			list[i][w]+=1

ans = [[0 for i in range(w)] for j in range(h)]
index=1
for i in range(0,h):
	if(list[i][w]!=0):
		flg=0
		for j in range(0,w):
#			print(index)
			if(list[i][j]==1):
				if(flg==0):
					flg=1
				else:
					index+=1
			ans[i][j] = index
		index+=1
#			print(list[i][j])
for i in range(1,h):
	if(list[i][w]==0)and(list[i-1][w]!=0):
		for j in range(0,w):
			ans[i][j]=ans[i-1][j]
		list[i][w]==1
for i in range(1,h):
	if(list[h-i][w]==0)and(list[h-i+1][w]!=0):
		for j in range(0,w):
			ans[h-i][j]=ans[h-i+1][j]
		list[h-i][w]==1

#print(list)
#print(ans)


for i in range(0,h):
	outstr=""
	for j in range(0,w):
		outstr+=str(ans[i][j])
		if(j!=w-1):
			outstr+=" "
	print(outstr)




Fixed submission:
# -*- coding: utf-8 -*-
#DISCO C
import sys
import math
import collections
#sys.setrecursionlimit(100000)

#n=int(input())

tmp = input().split()
h,w,k = list(map(lambda a: int(a), tmp))

list = [[0 for i in range(w+1)] for j in range(h)]
for i in range(0,h):
	tmp = input()
	for j in range(0,w):
		if(tmp[j]=='#'):
			list[i][j]+=1
			list[i][w]+=1

ans = [[0 for i in range(w)] for j in range(h)]
index=1
for i in range(0,h):
	if(list[i][w]!=0):
		flg=0
		for j in range(0,w):
			if(list[i][j]==1):
				if(flg==0):
					flg=1
				else:
					index+=1
			ans[i][j] = index
		index+=1
for i in range(1,h):
	if(list[i][w]==0)and(list[i-1][w]!=0):
		for j in range(0,w):
			ans[i][j]=ans[i-1][j]
		list[i][w]=1
for i in range(1,h):
	if(list[h-i-1][w]==0):
		for j in range(0,w):
			ans[h-i-1][j]=ans[h-i][j]
		list[h-i-1][w]=1

#print(list)
#print(ans)


for i in range(0,h):
	outstr=""
	for j in range(0,w):
		outstr+=str(ans[i][j])
		if(j!=w-1):
			outstr+=" "
	print(outstr)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
#ABC143D
import sys
import math
import collections
#sys.setrecursionlimit(100000)
 
 
n=int(input())
 
tmp = input().split()
l = list(map(lambda a: int(a), tmp))
 
sum=0
 
for i in range(n):
	for j in range(i+1,n):
		tmp1 = l[i]+l[j]
		tmp2 = abs(l[i]-l[j])
		for k in range(j+1,n):
			if((tmp1>l[k])and(tmp2<l[k])):
				sum+=1
print(sum)

Fixed submission:
# -*- coding: utf-8 -*-
#ABC143A
import sys
import math
import collections
#sys.setrecursionlimit(100000)


#n=int(input())

tmp = input().split()
a,b = list(map(lambda a: int(a), tmp))



sum = a
sum -=b
sum -=b
if (sum<0):
	sum=0


print(sum)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
#ABC136C
import copy
import sys
import math

n = int(input())
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
minhoge=hoge[n-1]
for i in range(1,n):
	t=n-1-i
	if(hoge[t]>minhoge+1):
		print("No")
		sys.exit()
	elif(hoge[t]<minhoge):
		minhoge=hoge[t]
	if(t==0):
		print("Yes")
		sys.exit()
print("Yes")





Fixed submission:
# -*- coding: utf-8 -*-
#ABC136D
import copy
import sys
import math

s = input()
n = len(s)

ans=[]
for i in range(0,n):
	ans.append(0)

count=0
for i in range(0,n):
	if(s[i]=="R"):
		count+=1
	else:
		ans[i]+=count//2
		ans[i-1]+=(count-1)//2+1
		count=0

count=0
for i in range(0,n):
	t=n-i-1
	if(s[t]=="L"):
		count+=1
	else:
		ans[t]+=count//2
		ans[t+1]+=(count-1)//2+1
		count=0

res=str(ans[0])
for i in range(1,n):
	res+=" "
	res+=(str(ans[i]))
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
#ABC122C
import sys
import copy
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
n=hoge[0]
q=hoge[1]

s = input()

l=[]
r=[]
sum=0
for i in range(0,q):
	tmp = input().split()
	hoge = list(map(lambda a: int(a), tmp))
	for j in range(hoge[0]-1,hoge[1]-1):
		#print(j)
		#print(hoge[0]-1)
		#print(hoge[1])
		if(s[j]=="A")and(s[j+1]=="C"):
			sum+=1
	print(sum)
	sum=0

Fixed submission:
# -*- coding: utf-8 -*-
#ABC122C
import sys
import copy
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
n=hoge[0]
q=hoge[1]

s = input()

ans=[]
sum=0
#print(s)

for j in range(0,n-1):
	if(s[j]=="A")and(s[j+1]=="C"):
		sum+=1
	ans.append(sum)
	#print(s[j])
ans.append(sum)
ans.append(0)
#ans[n-1]=sum
#print(ans)
#print(ans)

l=[]
r=[]
sum=0
for i in range(0,q):
	tmp = input().split()
	hoge = list(map(lambda a: int(a), tmp))

	print(ans[hoge[1]-2]-ans[hoge[0]-2])

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
#ABC122C
import sys
import copy
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
n=hoge[0]
q=hoge[1]

s = input()

l=[]
r=[]
for i in range(0,q):
	tmp = input().split()
	hoge = list(map(lambda a: int(a), tmp))
	l.append(hoge[0])
	r.append(hoge[1])

#print(s)

for i in range(0,q):
#	print(l[i])
#	print(r[i])
	tmp=copy.deepcopy(s[l[i]-1:r[i]])
#	print(s[3:7])
#	print(s[l[i]:r[i]])

#	print(tmp)
	
	lentmp = len(tmp)
	sum = 0
	for j in range(0,lentmp-1):
		if(tmp[j]=="A")and(tmp[j+1]=="C"):
			sum+=1
	print(sum)




Fixed submission:
# -*- coding: utf-8 -*-
#ABC122C
import sys
import copy
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
n=hoge[0]
q=hoge[1]

s = input()

ans=[]
sum=0
#print(s)

for j in range(0,n-1):
	if(s[j]=="A")and(s[j+1]=="C"):
		sum+=1
	ans.append(sum)
	#print(s[j])
ans.append(sum)
ans.append(0)
#ans[n-1]=sum
#print(ans)
#print(ans)

l=[]
r=[]
sum=0
for i in range(0,q):
	tmp = input().split()
	hoge = list(map(lambda a: int(a), tmp))

	print(ans[hoge[1]-2]-ans[hoge[0]-2])
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
#ABC120C

import sys
#import math

hoge = input()
#hoge=[]
#for i in range(0,len(tmp)):
#	hoge.append(tmp[i])
#hoge = list(map(lambda a: int(a), tmp))

n = len(hoge)

sum=0
i=0
while(1):
#	print(i)
	if(hoge[i]!=hoge[i+1]):
#		print("hoge:{} i:{} {} {}".format(hoge,i,hoge[i],hoge[i+1]))
		newhoge=hoge[0:i]+hoge[i+2:n]
		hoge = newhoge
		i=max(i-2,-1)
		n=len(hoge)
		sum+=2
#	print(i)
#	print("---")
	i+=1
	if(i>=n-1):
		break


print(sum)


Fixed submission:
# -*- coding: utf-8 -*-
#ABC120C

import sys
#import math

hoge = input()
n = len(hoge)

sum=0
i=0

while(1):
#	print(i)
	if(i>=n-1):
		break
	if(hoge[i]!=hoge[i+1]):
#		print("hoge:{} i:{} {} {}".format(hoge,i,hoge[i],hoge[i+1]))
		newhoge=hoge[0:i]+hoge[i+2:n]
		hoge=newhoge
		i-=1
		if(i<0):
			i=0
		n-=2
#		n=len(hoge)
		sum+=2
	else:
		i+=1


#	print(i)
#	print("---")


print(sum)

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

import sys
#import math

hoge = input()
#hoge=[]
#for i in range(0,len(tmp)):
#	hoge.append(tmp[i])
#hoge = list(map(lambda a: int(a), tmp))

n = len(hoge)

sum=0
i=0
while(1):
#	print(i)
	if(hoge[i]!=hoge[i+1]):
#		print("hoge:{} i:{} {} {}".format(hoge,i,hoge[i],hoge[i+1]))
		newhoge=hoge[0:i]+hoge[i+2:n]
		hoge = newhoge
		i=max(i-2,-1)
		n=len(hoge)
		sum+=2
#	print(i)
#	print("---")
	i+=1
	if(i>=n-2):
		break


print(sum)


Fixed submission:
# -*- coding: utf-8 -*-
#ABC120C

import sys
#import math

hoge = input()
n = len(hoge)

sum=0
i=0

while(1):
#	print(i)
	if(i>=n-1):
		break
	if(hoge[i]!=hoge[i+1]):
#		print("hoge:{} i:{} {} {}".format(hoge,i,hoge[i],hoge[i+1]))
		newhoge=hoge[0:i]+hoge[i+2:n]
		hoge=newhoge
		i-=1
		if(i<0):
			i=0
		n-=2
#		n=len(hoge)
		sum+=2
	else:
		i+=1


#	print(i)
#	print("---")


print(sum)

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

import sys
#import math

hoge = input()
#hoge=[]
#for i in range(0,len(tmp)):
#	hoge.append(tmp[i])
#hoge = list(map(lambda a: int(a), tmp))

n = len(hoge)

sum=0
i=0
while(1):
#	print(i)
	if(hoge[i]!=hoge[i+1]):
#		print("hoge:{} i:{} {} {}".format(hoge,i,hoge[i],hoge[i+1]))
		newhoge=hoge[0:i]+hoge[i+2:n]
		hoge = newhoge
		i=max(i-2,-1)
		n=len(hoge)
		sum+=2
#	print(i)
#	print("---")
	i+=1
	if(i>=n-1):
		break


print(sum)


Fixed submission:
# -*- coding: utf-8 -*-
#ABC120C

import sys
#import math

hoge = input()
n = len(hoge)

sum=0
i=0

while(1):
#	print(i)
	if(i>=n-1):
		break
	if(hoge[i]!=hoge[i+1]):
#		print("hoge:{} i:{} {} {}".format(hoge,i,hoge[i],hoge[i+1]))
		newhoge=hoge[0:i]+hoge[i+2:n]
		hoge=newhoge
		i-=1
		if(i<0):
			i=0
		n-=2
#		n=len(hoge)
		sum+=2
	else:
		i+=1


#	print(i)
#	print("---")


print(sum)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
#ABC116C
import sys

tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
n=hoge[0]
m=hoge[1]

tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

hoge.sort()
#print(hoge)
x=[]
sum=0
for i in range(0,m-1):
	x.append(hoge[i+1]-hoge[i])
	sum+=hoge[i+1]-hoge[i]
x.sort(reverse=True)

#print(x)

sc=0
for i in range(0,n-1):
	sc+=x[i]

print(sum-sc)



Fixed submission:
# -*- coding: utf-8 -*-
#ABC116C
import sys

tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
n=hoge[0]
m=hoge[1]

tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

hoge.sort()
#print(hoge)
x=[]
sum=0
for i in range(0,m-1):
	x.append(hoge[i+1]-hoge[i])
	sum+=hoge[i+1]-hoge[i]
x.sort(reverse=True)

#print(x)

sc=0
for i in range(0,min(n-1,len(x))):
	sc+=x[i]

print(sum-sc)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
#ABC112C
import sys

n = int(input())

x = []
y = []
h = []
for i in range(0,n):
	tmp = input().split()
	hoge = list(map(lambda a: int(a), tmp))
	x.append(hoge[0])
	y.append(hoge[1])
	h.append(hoge[2])

distance=0
height=0
#peak ga (i,j) to katei
for i in range(0,101):
	for j in range(0,101):
		distance=abs(i-x[0])
		distance+=abs(j-y[0])
		height=distance+h[0]

		for k in range(1,n):
			distance=abs(i-x[k])
			distance+=abs(j-y[k])
			if(height==distance+h[k]!):
				break
			if(k==n-1):
				print(i,j,height)
				sys.exit()

Fixed submission:
# -*- coding: utf-8 -*-
#ABC112C
import sys

n = int(input())

x = []
y = []
h = []
for i in range(0,n):
	tmp = input().split()
	hoge = list(map(lambda a: int(a), tmp))
	x.append(hoge[0])
	y.append(hoge[1])
	h.append(hoge[2])

distance=0
height=0

m=0
while(h[m]==0):
	m+=1
for i in range(0,101):
	for j in range(0,101):
		distance=abs(i-x[m])
		distance+=abs(j-y[m])
		height=distance+h[m]
		for k in range(0,n):
			distance=abs(i-x[k])
			distance+=abs(j-y[k])
			if(max(height-distance,0)!=h[k]):
				break
			if(k==n-1):
				print(i,j,height)
				sys.exit()
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
#ABC084C

tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
n=hoge[0]
y=hoge[1]

max10=y//10000
max5=y//5000
max1=y//1000

flg=0
for i in range(0,max10+1):
	for j in range(0,max5+1):
		for k in range(0,max1+1):
			if(i+j+k==n)and(i*10000+j*5000+k*1000==y):
				flg=1
				break
		else:
			continue
		break
	else:
		continue
	break
if flg:
	print("{} {} {}".format(i,j,k))
else:
	print("-1 -1 -1")




Fixed submission:
# -*- coding: utf-8 -*-
#ABC084C

tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
n=hoge[0]
y=hoge[1]

max10=y//10000
max5=y//5000
max1=y//1000

flg=0
for i in range(0,max10+1):
	for j in range(0,max5+1):
		k=n-i-j
		if(k>=0)and(i*10000+j*5000+k*1000==y):
			flg=1
			break
	else:
		continue
	break
if flg:
	print("{} {} {}".format(i,j,k))
else:
	print("-1 -1 -1")