Buggy python submission (verdict: Runtime Error):
def signal(a,e):
	s=""
	for i in range(7):
		s+="0" if a[i]==e[i] else "1"
	return s

ref=["0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"]
while 1:
	n=int(raw_input())
	if n==-1:break
	e="0000000"
	for i in range(n):
		a=ref[int(raw_input())]
		print signal(a,e)
		e=a

Fixed submission:
# try-except is necessary for avoiding Runtime Error 
while 1:
	try:
		n,m=map(int,raw_input().split())
		if n==0:break
		v=sorted(map(int,raw_input().split()))[::-1]
		for i in range(m-1,n,m):
			v[i]=0
		print sum(v)
	except:
		pass

Buggy python submission (verdict: Runtime Error):
while 1:
	n,m=map(int, raw_input().split())
	if n==0:break
	c=sorted(map(int,raw_input().split()))[::-1]
	c[m-1::m] = [0 for i in range(m-1,n,m)]
	print sum(c)
	

Fixed submission:
# try-except is necessary for avoiding Runtime Error 
while 1:
	try:
		n,m=map(int,raw_input().split())
		if n==0:break
		v=sorted(map(int,raw_input().split()))[::-1]
		for i in range(m-1,n,m):
			v[i]=0
		print sum(v)
	except:
		pass

Buggy python submission (verdict: Runtime Error):
while 1:
	n,m=map(int, raw_input().split())
	if n==0:break
	c=sorted(map(int,raw_input().split()))[::-1]
	if m > n:
		print sum(c)
	else:
		c[m-1::m] = [0 for i in range(m-1,n,m)]
		print sum(c)
	

Fixed submission:
# try-except is necessary for avoiding Runtime Error 
while 1:
	try:
		n,m=map(int,raw_input().split())
		if n==0:break
		v=sorted(map(int,raw_input().split()))[::-1]
		for i in range(m-1,n,m):
			v[i]=0
		print sum(v)
	except:
		pass

Buggy python submission (verdict: Runtime Error):
while 1:
	n,m=map(int, raw_input().split())
	if n==0:break
#	c=sorted(map(int,raw_input().split()))[::-1]
#	if m > n:
#		print sum(c)
#	else:
#		c[m-1::m] = [0 for i in range(m-1,n,m)]
#		print sum(c)
	

Fixed submission:
# try-except is necessary for avoiding Runtime Error 
while 1:
	try:
		n,m=map(int,raw_input().split())
		if n==0:break
		v=sorted(map(int,raw_input().split()))[::-1]
		for i in range(m-1,n,m):
			v[i]=0
		print sum(v)
	except:
		pass

Buggy python submission (verdict: Runtime Error):
while True:
	n,m=map(int, raw_input().split())
	if n==0:break
#	c=sorted(map(int,raw_input().split()))[::-1]
#	if m > n:
#		print sum(c)
#	else:
#		c[m-1::m] = [0 for i in range(m-1,n,m)]
#		print sum(c)
	

Fixed submission:
# try-except is necessary for avoiding Runtime Error 
while 1:
	try:
		n,m=map(int,raw_input().split())
		if n==0:break
		v=sorted(map(int,raw_input().split()))[::-1]
		for i in range(m-1,n,m):
			v[i]=0
		print sum(v)
	except:
		pass

Buggy python submission (verdict: Runtime Error):
while True:
	n,m=map(int, raw_input().split())
	if n==0:break
	c=sorted(map(int,raw_input().split()))[::-1]
#	if m > n:
#		print sum(c)
#	else:
#		c[m-1::m] = [0 for i in range(m-1,n,m)]
#		print sum(c)
	

Fixed submission:
# try-except is necessary for avoiding Runtime Error 
while 1:
	try:
		n,m=map(int,raw_input().split())
		if n==0:break
		v=sorted(map(int,raw_input().split()))[::-1]
		for i in range(m-1,n,m):
			v[i]=0
		print sum(v)
	except:
		pass

Buggy python submission (verdict: Runtime Error):
while 1:
    n=map(int, raw_input().split())
    if n[0]==0:break
#   c=sorted(map(int,raw_input().split()))[::-1]
#   if m > n:
#       print sum(c)
#   else:
#       c[m-1::m] = [0 for i in range(m-1,n,m)]
#       print sum(c)

Fixed submission:
# try-except is necessary for avoiding Runtime Error 
while 1:
	try:
		n,m=map(int,raw_input().split())
		if n==0:break
		v=sorted(map(int,raw_input().split()))[::-1]
		for i in range(m-1,n,m):
			v[i]=0
		print sum(v)
	except:
		pass

Buggy python submission (verdict: Runtime Error):
while 1:
	n,m=map(int,raw_input().split())
	if n==0:break
	v=sorted(map(int,raw_input().split()))[::-1]
	for i in range(m-1,n,m):
		v[i]=0
	print sum(v)

Fixed submission:
# try-except is necessary for avoiding Runtime Error 
while 1:
	try:
		n,m=map(int,raw_input().split())
		if n==0:break
		v=sorted(map(int,raw_input().split()))[::-1]
		for i in range(m-1,n,m):
			v[i]=0
		print sum(v)
	except:
		pass