Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
while True:
    _=input()
    if _ == '-':
        break
    for i in range(int(input())):
        l=int(input())
        _=_[l:]+[:l]
    print(_)    


Fixed submission:
while True:
    _=input()
    if _ == '-':
        break
    for i in range(int(input())):
        l=int(input())
        _=_[l:]+_[:l]
    print(_)
Buggy python submission (verdict: Runtime Error):
a = list(map(int,input().split()))
a.sort()
for i in range(1,4):
    print(a[-i])

Fixed submission:
a = []
for i in range(10):
    a.append(int(input()))
a.sort()
for j in range(3):
    print(a[-(j+1)])

Buggy python submission (verdict: Runtime Error):
a = list(map(int,input().split()))
a.sort()
print(a[-1])
print(a[-2])
print(a[-3])

Fixed submission:
a = []
for i in range(10):
    a.append(int(input()))
a.sort()
for j in range(3):
    print(a[-(j+1)])
Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split())
e = math.sqrt((c-a)**2+(d-b)**2)
print(e)

Fixed submission:
from math import sqrt
a,b,c,d = map(float,input().split())
print(sqrt((c-a)**2+(d-b)**2))

Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split())
e = math.sqrt((c-a)**2+(d-b)**2)
print(e)

Fixed submission:
from math import sqrt
a,b,c,d = map(float,input().split())
print(sqrt((c-a)**2+(d-b)**2))

Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split())
e = math.sqrt((c-a)**2+(d-b)**2)
print(e)

Fixed submission:
from math import sqrt
a,b,c,d = map(float,input().split())
print(sqrt((c-a)**2+(d-b)**2))

Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split())
print(math.sqrt((c-a)**2+(d-b)**2))

Fixed submission:
from math import sqrt
a,b,c,d = map(float,input().split())
print(sqrt((c-a)**2+(d-b)**2))

Buggy python submission (verdict: Runtime Error):
from math import sqrt
a,b,c,d = map(int,input().split())
print(math.sqrt((c-a)**2+(d-b)**2))

Fixed submission:
from math import sqrt
a,b,c,d = map(float,input().split())
print(sqrt((c-a)**2+(d-b)**2))

Buggy python submission (verdict: Runtime Error):
from math import sqrt
a,b,c,d = map(int,input().split())
print(sqrt((c-a)**2+(d-b)**2))

Fixed submission:
from math import sqrt
a,b,c,d = map(float,input().split())
print(sqrt((c-a)**2+(d-b)**2))
Buggy python submission (verdict: Runtime Error):
input(i)
print(i**3)

Fixed submission:
x = input()
print(int(x)**3)

Buggy python submission (verdict: Runtime Error):
input(i)
print(i**3)

Fixed submission:
x = input()
print(int(x)**3)
Buggy python submission (verdict: Runtime Error):
x=int(input())
y=int(input())
print(x*y)

Fixed submission:
x,y = map(int,input().split())
print(x*y,(x+y)*2)
Buggy python submission (verdict: Runtime Error):
import math
r = int(input())
print("%d %d"%(math.pi*r*r,2*math.pi*r))

Fixed submission:
import math
r = float(input())
print("%f %f"%(math.pi*r*r,2*math.pi*r))
Buggy python submission (verdict: Runtime Error):
even = "#." * 151
odd = ".#" * 151
while 1:
    h,w = map(int,input().split())
    if h == w ==0:
        break
    for i in range(h//2):
        print(even[:w])
        print(odd[:w])
    if h%2 != 0:
        print(even[:w])

Fixed submission:
even = "#." * 151
odd = ".#" * 151
while 1:
    h,w = map(int,input().split())
    if h == w ==0:
        break
    for i in range(h//2):
        print(even[:w])
        print(odd[:w])
    if h%2 != 0:
        print(even[:w])
    print()
Buggy python submission (verdict: Runtime Error):
n = int(input())
num = list(map(int,input().split()))
for i in range(n):
    print(num[n-i-1],end = " ")

Fixed submission:
n =int(input())
a = list(map(int,input().split()))
a.reverse()
for i in range(n):
    if i!=n-1:
        print(a[i],end=" ")
    else:
        print(a[i])

Buggy python submission (verdict: Runtime Error):
n = int(input())
num = list(map(int,input().split()))
num.reverse()
for i in range(n-1):
    print(num[i],end = " ")
print(num[n-1])

Fixed submission:
n =int(input())
a = list(map(int,input().split()))
a.reverse()
for i in range(n):
    if i!=n-1:
        print(a[i],end=" ")
    else:
        print(a[i])
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
A =[[int(i) for i in input().split()] for j in range(n)]
b = []
for i in range(m):
    b.append(int(input()))
ans = [0,0,0]
for i in range(n):
    for j in range(m):
        ans += A[i][j]*b[j]
print(ans)

Fixed submission:
n,m=map(int,input().split())
A =[[int(i) for i in input().split()] for j in range(n)]
b = []
for i in range(m):
    b.append(int(input()))
ans = [0 for i in range(n)]
for i in range(n):
    for j in range(m):
        ans[i] += A[i][j]*b[j]
for i in ans:
    print(i)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
A =[[int(i) for i in input().split()] for j in range(n)]
b = []
for i in range(m):
    b.append(int(input()))
ans = [0 for i in range(m)]
for i in range(n):
    for j in range(m):
        ans[i] += A[i][j]*b[j]
for i in ans:
    print(i))

Fixed submission:
n,m=map(int,input().split())
A =[[int(i) for i in input().split()] for j in range(n)]
b = []
for i in range(m):
    b.append(int(input()))
ans = [0 for i in range(n)]
for i in range(n):
    for j in range(m):
        ans[i] += A[i][j]*b[j]
for i in ans:
    print(i)
Buggy python submission (verdict: Runtime Error):
cnt = 0
s = input().lower()
while 1:
    W = input().lower().split()
    if W == "END_OF_TEXT":
        break
    elif W == s:
        cnt += 1
print(cnt)

Fixed submission:
cnt = 0
s = input().lower()
while 1:
    line = input()
    if line == "END_OF_TEXT":
        break
    for w in line.lower().split():
        if w == s:
            cnt+=1
print(cnt)

Buggy python submission (verdict: Runtime Error):
cnt = 0
s = input().lower()
while 1:
    W = input().split().lower
    if W == "END_OF_TEXT":
        break
    elif W == s:
        cnt += 1
print(cnt)

Fixed submission:
cnt = 0
s = input().lower()
while 1:
    line = input()
    if line == "END_OF_TEXT":
        break
    for w in line.lower().split():
        if w == s:
            cnt+=1
print(cnt)

Buggy python submission (verdict: Runtime Error):
cnt = 0
s = input().lower()
while 1:
    line = input()
    if W == "END_OF_TEXT":
        break
    for s in line.lower().split():
print(cnt)

Fixed submission:
cnt = 0
s = input().lower()
while 1:
    line = input()
    if line == "END_OF_TEXT":
        break
    for w in line.lower().split():
        if w == s:
            cnt+=1
print(cnt)

Buggy python submission (verdict: Runtime Error):
cnt = 0
s = input().lower()
while 1:
    line = input()
    if line == "END_OF_TEXT":
        break
    for s in line.lower().split():
print(cnt)

Fixed submission:
cnt = 0
s = input().lower()
while 1:
    line = input()
    if line == "END_OF_TEXT":
        break
    for w in line.lower().split():
        if w == s:
            cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
ap,bp = 0
n = int(input())
for i in range(n):
    a,b = input().split()
    if a>b:
        ap+=3
    elif a==b:
        bp+=3
    else:
        bp+=3
    print(ap,bp)

Fixed submission:
ap,bp = 0,0
n = int(input())
for i in range(n):
    a,b = input().split()
    if a>b:
        ap+=3
    elif a==b:
        ap+=1
        bp+=1
    else:
        bp+=3
print(ap,bp)
Buggy python submission (verdict: Runtime Error):
inp = input()
a = [input() for i in range(inp)]
a.sort()
a.reverse()
print(a[0])
print(a[1])
print(a[2])

Fixed submission:
import sys

a = []
for line in sys.stdin:
    a.append(int(line))
a.sort()
a.reverse()
print(a[0])
print(a[1])
print(a[2])

Buggy python submission (verdict: Runtime Error):
inp = input()
a = [input() for i in range(int(inp))]
a.sort()
a.reverse()
print(a[0])
print(a[1])
print(a[2])

Fixed submission:
import sys

a = []
for line in sys.stdin:
    a.append(int(line))
a.sort()
a.reverse()
print(a[0])
print(a[1])
print(a[2])

Buggy python submission (verdict: Runtime Error):
inp = input()
a = [input() for i in range(int(inp))]
a.sort()
a.reverse()
print(a[0])
print(a[1])
print(a[2])

Fixed submission:
import sys

a = []
for line in sys.stdin:
    a.append(int(line))
a.sort()
a.reverse()
print(a[0])
print(a[1])
print(a[2])
Buggy python submission (verdict: Runtime Error):
def ge(arr):
    for i in range(len(arr)):
        tmp = int(arr[i])
        if tmp >= 4:
            tmp += 1
        if tmp >= 6:
            tmp += 1
        arr[i] = str(tmp)


while True:
    n = int(input)
    if n == 0:
        break
    print("".join(ge(list(oct(n))[2:])))


Fixed submission:
def ge(arr):
    for i in range(len(arr)):
        tmp = int(arr[i])
        if tmp >= 4:
            tmp += 1
        if tmp >= 6:
            tmp += 1
        arr[i] = str(tmp)
    return arr


while True:
    n = int(input())
    if n == 0:
        break
    print("".join(ge(list(oct(n))[2:])))
Buggy python submission (verdict: Runtime Error):
import copy

(h, w, n) = list(map(int, input().split()))
dis = [[] for i in range(n + 1)]


def setArr(ph):
    global dis
    res = [False for i in range(w + 2)]
    for i, x in enumerate(list(input())):
        if x == "X":
            continue
        res[i + 1] = True
        if x == ".":
            continue
        if x == "S":
            dis[0] = [ph, i + 1]
            continue
        dis[int(x)] = [ph, i + 1]
    return res


arr = [[] for i in range(h + 2)]
arr[0] = [False for i in range(h + 2)]
arr[-1] = [False for i in range(h + 2)]
for i in range(1, h + 1):
    arr[i] = setArr(i)
res = 0
move = [[1, 0], [0, 1], [-1, 0], [0, -1]]


def ze(start, goal):
    arra = copy.deepcopy(arr)
    global res
    queue = [start, [-1, -1]]
    ap = queue.append
    zu = False
    for q in queue:
        if q[0] < 0:
            res += 1
            ap([-1, -1])
            continue
        if not arra[q[0]][q[1]]:
            continue
        for m in move:
            de = [q[0] + m[0], q[1] + m[1]]
            if de == goal:
                res += 1
                zu = True
                break
            if arra[de[0]][de[1]]:
                ap(de)
        if zu:
            break
        arra[q[0]][q[1]] = False


for i in range(n):
    ze(dis[i], dis[i + 1])

print(res)


Fixed submission:
import copy

(h, w, n) = list(map(int, input().split()))
dis = [[] for i in range(n + 1)]


def setArr(ph):
    global dis
    res = [False for i in range(w + 2)]
    for i, x in enumerate(list(input())):
        if x == "X":
            continue
        res[i + 1] = True
        if x == ".":
            continue
        if x == "S":
            dis[0] = [ph, i + 1]
            continue
        dis[int(x)] = [ph, i + 1]
    return res


arr = [[] for i in range(h + 2)]
arr[0] = [False for i in range(w + 2)]
arr[-1] = [False for i in range(w + 2)]
for i in range(1, h + 1):
    arr[i] = setArr(i)

res = 0
move = [[1, 0], [0, 1], [-1, 0], [0, -1]]


def ze(start, goal):
    arra = copy.deepcopy(arr)
    global res
    queue = [start, [-1, -1]]
    ap = queue.append
    zu = False
    for q in queue:
        if q[0] < 1:
            res += 1
            ap([-1, -1])
            continue
        if not arra[q[0]][q[1]]:
            continue
        for m in move:
            de = [q[0] + m[0], q[1] + m[1]]

            if de == goal:
                res += 1
                zu = True
                break
            if arra[de[0]][de[1]]:
                ap(de)
        if zu:
            break
        arra[q[0]][q[1]] = False


for i in range(n):
    ze(dis[i], dis[i + 1])

print(res)
Buggy python submission (verdict: Runtime Error):
import math
while True:
    line = input().split(" ")
    if(len(line) != 2):
        exit()
    a = int(line[0])
    b = int(line[1])
    print(int(math.log10(a+b))+1)

Fixed submission:
import math
while True:
    try:
        line = input().split(" ")
        print(int(math.log10(int(line[0])+int(line[1])))+1)
    except:
        break

Buggy python submission (verdict: Runtime Error):
#import math
while True:
    line = input().split(" ")
    if(len(line) != 2):
        exit()
    a = int(line[0])
    b = int(line[1])
    print(int(math.log10(a+b))+1)

Fixed submission:
import math
while True:
    try:
        line = input().split(" ")
        print(int(math.log10(int(line[0])+int(line[1])))+1)
    except:
        break

Buggy python submission (verdict: Runtime Error):
import numpy.math
while True:
    line = input().split(" ")
    if(len(line) != 2):
        exit()
    a = int(line[0])
    b = int(line[1])
    print(int(math.log10(a+b))+1)

Fixed submission:
import math
while True:
    try:
        line = input().split(" ")
        print(int(math.log10(int(line[0])+int(line[1])))+1)
    except:
        break

Buggy python submission (verdict: Runtime Error):
import math
while True:
    line = input().split(" ")
    if(len(line) != 2):
        break
    a = int(line[0])
    b = int(line[1])
    print(int(math.log10(a+b))+1)

Fixed submission:
import math
while True:
    try:
        line = input().split(" ")
        print(int(math.log10(int(line[0])+int(line[1])))+1)
    except:
        break
Buggy python submission (verdict: Runtime Error):
n=input()
for i in range(0,n):
????????num=map(int, raw_input().split())
????????num.sort()
????????a=num[0]
????????b=num[1]
????????c=num[2]
????????if c*c==a*a+b*b:
????????????????print ("YES")
????????else:
????????????????print ("NO")

Fixed submission:
import sys
for i in sys.stdin:
    try:
        sidelen = [int(j) for j in i.split(" ")]
        sidelen.sort(reverse=True)
        if(sidelen[0]**2 == sidelen[1]**2 + sidelen[2]**2):
            print("YES")
        else:
            print("NO")
    except:
        continue

Buggy python submission (verdict: Runtime Error):
n=input()
for i in range(0,n):
????????num=map(int, input().split())
????????num.sort()
????????a=num[0]
????????b=num[1]
????????c=num[2]
????????if c*c==a*a+b*b:
????????????????print ("YES")
????????else:
????????????????print ("NO")

Fixed submission:
import sys
for i in sys.stdin:
    try:
        sidelen = [int(j) for j in i.split(" ")]
        sidelen.sort(reverse=True)
        if(sidelen[0]**2 == sidelen[1]**2 + sidelen[2]**2):
            print("YES")
        else:
            print("NO")
    except:
        continue
Buggy python submission (verdict: Runtime Error):
ef Round(ip, dg):  # ip???dg?????§?????¨?????\????????¢??°
    ip = ip / 10**dg
    if(ip-int(ip) != 0):
        return (int(ip) + 1)*10**dg
    else:
        return int(ip)*10**dg


n=int(input())
sum=100000
for i in range(0, n):
    sum=Round(sum*1.05)
print(sum)

Fixed submission:
def Round(ip, dg):  # ip???dg?????§?????¨?????\????????¢??°
    ip = ip / 10**dg
    if(ip-int(ip) != 0):
        return (int(ip) + 1)*10**dg
    else:
        return int(ip)*10**dg


n=int(input())
sum=100000
for i in range(0, n):
    sum=Round(sum*1.05, 3)
print(sum)
Buggy python submission (verdict: Runtime Error):
while(True):
    try:
        weight = float(input())

        if(weight <= 48.00):
            print("light fly")
        elif(weight <= 51.00):
            print("fly")
        elif(weight <= 54.00):
            print("bantam")
        elif(weight <= 57.00):
            print("feather")
        elif(weight <= 60.00):
            print("light")
        elif(weight <= 64.00):
            print("light welter")
        elif(weight <= 69.00):
            print("welter")
        elif(weight <= 75.00):
            print("light middle")
        elif(weight <= 81.00):
            print("middle")
        elif(weight <= 91.00):
            print("light heavy")
        else:
            print("heavy")
    except ValueError:
        break;



Fixed submission:
# AOJ 0048
# Class
# 5/1/2019

min = 40.00
max = 150.00

measure = [min, 48.00, 51.00, 54.00, 57.00, 60.00, 64.00, 69.00, 75.00, 81.00, 91.00, max]
className = ['light fly',
         'fly',
         'bantam',
         'feather',
         'light',
         'light welter',
         'welter',
         'light middle',
         'middle',
         'light heavy',
         'heavy']

while True:
    try:
        weight = float(input())
    except:
        break;
    for i in range(11):
        if(measure[i] < weight and weight <= measure[i + 1]):
            print(className[i])

Buggy python submission (verdict: Runtime Error):
while 1:
    try:
        weight = float(input())

        if(weight <= 48.00):
            print("light fly")
        elif(weight <= 51.00):
            print("fly")
        elif(weight <= 54.00):
            print("bantam")
        elif(weight <= 57.00):
            print("feather")
        elif(weight <= 60.00):
            print("light")
        elif(weight <= 64.00):
            print("light welter")
        elif(weight <= 69.00):
            print("welter")
        elif(weight <= 75.00):
            print("light middle")
        elif(weight <= 81.00):
            print("middle")
        elif(weight <= 91.00):
            print("light heavy")
        else:
            print("heavy")
    except ValueError:
        break;



Fixed submission:
# AOJ 0048
# Class
# 5/1/2019

min = 40.00
max = 150.00

measure = [min, 48.00, 51.00, 54.00, 57.00, 60.00, 64.00, 69.00, 75.00, 81.00, 91.00, max]
className = ['light fly',
         'fly',
         'bantam',
         'feather',
         'light',
         'light welter',
         'welter',
         'light middle',
         'middle',
         'light heavy',
         'heavy']

while True:
    try:
        weight = float(input())
    except:
        break;
    for i in range(11):
        if(measure[i] < weight and weight <= measure[i + 1]):
            print(className[i])
Buggy python submission (verdict: Runtime Error):
r=float(input())
string=str(r**2*3.141592)+" "+str(2*3.141592*r)
print(string)

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

string=str(a[0]//a[1])+" "+str(a[0]%a[1])+" "+str("%.10f"%(a[0]/a[1]))
print(string)
Buggy python submission (verdict: Runtime Error):
a=list(map(int,input().split()))

string=str(a[0]**2*3.141592)+" "+str(2*3.141592*a[0])
print(string)

Fixed submission:
import math
r=float(input())
string=str(r**2*math.pi)+" "+str(2*math.pi*r)
print(string)
Buggy python submission (verdict: Runtime Error):
#include <iostream>
using namespace std;
int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    if(a < b && b < c) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}



Fixed submission:
a,b,c = map(int, input().split())
if a<b and b<c:
	print("Yes")
else:
	print("No")
Buggy python submission (verdict: Runtime Error):
def get_input():
    while True:
        try:
            yield ''.join(raw_input())
        except EOFError:
            break

ar = [0] * 50

for i in range(10):
	for j in range(10):
		for k in range(10):
			for l in range(10):
				ar[i + j + k + l] += 1

for a in list(get_input()):

	print ar[int(a)]

Fixed submission:
def get_input():
    while True:
        try:
            yield ''.join(raw_input())
        except EOFError:
            break

ar = [0] * 51

for i in range(10):
	for j in range(10):
		for k in range(10):
			for l in range(10):
				ar[i + j + k + l] += 1

for a in list(get_input()):

	print ar[int(a)]
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
#-*- coding:utf-8 -*-
while True:
	n = input()
	if n == 0: break
	a = [ input() for i in xrange(n) ]
	m = -100000
	for i in xrange(n):
		for j in xrange(n + 1):
			m = max(m, sum(a[i:j]))
	print m

Fixed submission:
#!/usr/bin/env python
#-*- coding:utf-8 -*-
while True:
	n = input()
	if n == 0: break
	a = [ input() for i in xrange(n) ]
	m = -100000
	for i in xrange(n):
		s = 0
		for j in xrange(i, n):
			s += a[j]
			m = max(m, s)
	print m
Buggy python submission (verdict: Runtime Error):
import sys
patterns = [[1, 2, 1, 2, 1, 4, 1, 4],
 [1, 2, 1, 4, 1, 4, 1, 2],
 [1, 4, 1, 4, 1, 2, 1, 2],
 [2, 1, 2, 1, 4, 1, 4, 1],
 [2, 1, 4, 1, 4, 1, 2, 1],
 [4, 1, 2, 1, 2, 1, 4, 1],
 [4, 1, 4, 1, 2, 1, 2, 1],
]

for line in sys.stdin:
	p = [int(x) for x in line.split()]
	m = sum(p)
	pt = None
	for ptn in patterns:
		rem = sum(max(0, v - x) for v, x in zip(ptn, p))
		if rem < m:
			m = rem
			pt = ptn
	print " ".join([str(x) for x in pt])

Fixed submission:
import sys
patterns = [
	[1, 2, 1, 2, 1, 4, 1, 4],
	[1, 2, 1, 4, 1, 4, 1, 2],
	[1, 4, 1, 2, 1, 2, 1, 4],
	[1, 4, 1, 4, 1, 2, 1, 2],
	[2, 1, 2, 1, 4, 1, 4, 1],
	[2, 1, 4, 1, 4, 1, 2, 1],
	[4, 1, 2, 1, 2, 1, 4, 1],
	[4, 1, 4, 1, 2, 1, 2, 1],
]

while True:
	try:
		p = [int(x) for x in raw_input().split()]
		m = 999999999
		for ptn in patterns:
			rem = sum(max(0, v - x) for v, x in zip(ptn, p))
			if rem < m:
				m = rem
				pt = ptn
		print " ".join([str(x) for x in pt])
	except:
		break

Buggy python submission (verdict: Runtime Error):
import sys
patterns = [[1, 2, 1, 2, 1, 4, 1, 4],
 [1, 2, 1, 4, 1, 4, 1, 2],
 [1, 4, 1, 4, 1, 2, 1, 2],
 [2, 1, 2, 1, 4, 1, 4, 1],
 [2, 1, 4, 1, 4, 1, 2, 1],
 [4, 1, 2, 1, 2, 1, 4, 1],
 [4, 1, 4, 1, 2, 1, 2, 1],
]

for line in sys.stdin:
	if not line: continue
	p = [int(x) for x in line.split()]
	m = sum(p)
	pt = None
	for ptn in patterns:
		rem = sum(max(0, v - x) for v, x in zip(ptn, p))
		if rem < m:
			m = rem
			pt = ptn
	print " ".join([str(x) for x in pt])

Fixed submission:
import sys
patterns = [
	[1, 2, 1, 2, 1, 4, 1, 4],
	[1, 2, 1, 4, 1, 4, 1, 2],
	[1, 4, 1, 2, 1, 2, 1, 4],
	[1, 4, 1, 4, 1, 2, 1, 2],
	[2, 1, 2, 1, 4, 1, 4, 1],
	[2, 1, 4, 1, 4, 1, 2, 1],
	[4, 1, 2, 1, 2, 1, 4, 1],
	[4, 1, 4, 1, 2, 1, 2, 1],
]

while True:
	try:
		p = [int(x) for x in raw_input().split()]
		m = 999999999
		for ptn in patterns:
			rem = sum(max(0, v - x) for v, x in zip(ptn, p))
			if rem < m:
				m = rem
				pt = ptn
		print " ".join([str(x) for x in pt])
	except:
		break
Buggy python submission (verdict: Runtime Error):
while True:
	n, m = (int(x) for x in raw_input().split(" "))
	if n == 0 and m == 0: break
	p = [int(x) for x in raw_input().split(" ")]
	s = sum(p)
	p.sort(reverse=True)
	for x in p[m - 1::m]:
		s -= x
	print s

Fixed submission:
while True:
	try:
		n, m = (int(x.strip()) for x in raw_input().split())
		if n == 0 and m == 0: break
		p = [int(x.strip()) for x in raw_input().split()]
		s = sum(p)
		p.sort(reverse=True)
		for x in p[m - 1::m]:
			s -= x
		print s
	except:
		pass

Buggy python submission (verdict: Runtime Error):
while True:
	n, m = (int(x) for x in raw_input().split())
	if n == 0 and m == 0: break
	p = [int(x) for x in raw_input().split()]
	s = sum(p)
	p.sort(reverse=True)
	for x in p[m - 1::m]:
		s -= x
	print s

Fixed submission:
while True:
	try:
		n, m = (int(x.strip()) for x in raw_input().split())
		if n == 0 and m == 0: break
		p = [int(x.strip()) for x in raw_input().split()]
		s = sum(p)
		p.sort(reverse=True)
		for x in p[m - 1::m]:
			s -= x
		print s
	except:
		pass

Buggy python submission (verdict: Runtime Error):
while True:
	n, m = (int(x.strip()) for x in raw_input().split())
	if n == 0 and m == 0: break
	p = [int(x.strip()) for x in raw_input().split()]
	s = sum(p)
	p.sort(reverse=True)
	for x in p[m - 1::m]:
		s -= x
	print s

Fixed submission:
while True:
	try:
		n, m = (int(x.strip()) for x in raw_input().split())
		if n == 0 and m == 0: break
		p = [int(x.strip()) for x in raw_input().split()]
		s = sum(p)
		p.sort(reverse=True)
		for x in p[m - 1::m]:
			s -= x
		print s
	except:
		pass