Buggy python submission (verdict: Runtime Error):
while True:
    n,m = list(map(int,input().split()))
    if n == 0 and m == 0:
        break

    amari = n % m
    yasai = list(map(int,input().split())) 
    yasai.sort()

    s = 0
    if amari > 0:
        s = sum(yasai[0:amari])

    i = 0
    for y in yasai[amari:]:
        if i % m > 0:
            s += y
        i+=1

    print(s)

Fixed submission:
while True:
    try:
        n,m = list(map(int,input().split()))
        if n == 0 and m == 0:
            break
        amari = n % m
        yasai = list(map(int,input().split())) 
        yasai.sort()

        s = 0
        for i in range(n):
            if (i+1) % m > 0:
                s += yasai[-i-1]
        print(s)
    except:
        pass

Buggy python submission (verdict: Runtime Error):
while True:
    n,m = list(map(int,input().split()))
    if n == 0 and m == 0:
        break

    amari = n % m
    yasai = list(map(int,input().split())) 
    yasai.sort()

    s = 0
    if amari > 0:
        s = sum(yasai[0:amari])

    i = 0
    for y in yasai[amari:]:
        pass

    print(s)

Fixed submission:
while True:
    try:
        n,m = list(map(int,input().split()))
        if n == 0 and m == 0:
            break
        amari = n % m
        yasai = list(map(int,input().split())) 
        yasai.sort()

        s = 0
        for i in range(n):
            if (i+1) % m > 0:
                s += yasai[-i-1]
        print(s)
    except:
        pass

Buggy python submission (verdict: Runtime Error):
while True:
    n,m = list(map(int,input().split()))
    if n == 0 and m == 0:
        break

    amari = int(n % m)
    yasai = list(map(int,input().split())) 
    yasai.sort()

    s = 0
    if amari > 0:
        s = sum(yasai[0:amari])

    i = 0
    for y in yasai[amari:]:
        pass
        if i % m > 0:
            s += y
        i+=1

    print(s)

Fixed submission:
while True:
    try:
        n,m = list(map(int,input().split()))
        if n == 0 and m == 0:
            break
        amari = n % m
        yasai = list(map(int,input().split())) 
        yasai.sort()

        s = 0
        for i in range(n):
            if (i+1) % m > 0:
                s += yasai[-i-1]
        print(s)
    except:
        pass

Buggy python submission (verdict: Runtime Error):
while True:
    n,m = list(map(int,input().split()))
    if n == 0 and m == 0:
        break

    amari = int(n % m)
    yasai = list(map(int,input().split())) 
    print(amari)

Fixed submission:
while True:
    try:
        n,m = list(map(int,input().split()))
        if n == 0 and m == 0:
            break
        amari = n % m
        yasai = list(map(int,input().split())) 
        yasai.sort()

        s = 0
        for i in range(n):
            if (i+1) % m > 0:
                s += yasai[-i-1]
        print(s)
    except:
        pass

Buggy python submission (verdict: Runtime Error):
while True:
    n,m = list(map(int,input().split()))
    print(amari)

Fixed submission:
while True:
    try:
        n,m = list(map(int,input().split()))
        if n == 0 and m == 0:
            break
        amari = n % m
        yasai = list(map(int,input().split())) 
        yasai.sort()

        s = 0
        for i in range(n):
            if (i+1) % m > 0:
                s += yasai[-i-1]
        print(s)
    except:
        pass

Buggy python submission (verdict: Runtime Error):
while True:
    #n,m = list(map(int,input().split()))
    spam = input().split()
    n = int(spam[0])
    m = int(spam[1])
    if n == 0 and m == 0:
        break


    print(1)

Fixed submission:
while True:
    try:
        n,m = list(map(int,input().split()))
        if n == 0 and m == 0:
            break
        amari = n % m
        yasai = list(map(int,input().split())) 
        yasai.sort()

        s = 0
        for i in range(n):
            if (i+1) % m > 0:
                s += yasai[-i-1]
        print(s)
    except:
        pass

Buggy python submission (verdict: Runtime Error):
while True:
    #n,m = list(map(int,input().split()))
    spam = input().split()


    print(1)

Fixed submission:
while True:
    try:
        n,m = list(map(int,input().split()))
        if n == 0 and m == 0:
            break
        amari = n % m
        yasai = list(map(int,input().split())) 
        yasai.sort()

        s = 0
        for i in range(n):
            if (i+1) % m > 0:
                s += yasai[-i-1]
        print(s)
    except:
        pass

Buggy python submission (verdict: Runtime Error):
while True:
    #n,m = list(map(int,input().split()))
    spam = input()


    print(1)

Fixed submission:
while True:
    try:
        n,m = list(map(int,input().split()))
        if n == 0 and m == 0:
            break
        amari = n % m
        yasai = list(map(int,input().split())) 
        yasai.sort()

        s = 0
        for i in range(n):
            if (i+1) % m > 0:
                s += yasai[-i-1]
        print(s)
    except:
        pass

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


    print(1)

Fixed submission:
while True:
    try:
        n,m = list(map(int,input().split()))
        if n == 0 and m == 0:
            break
        amari = n % m
        yasai = list(map(int,input().split())) 
        yasai.sort()

        s = 0
        for i in range(n):
            if (i+1) % m > 0:
                s += yasai[-i-1]
        print(s)
    except:
        pass

Buggy python submission (verdict: Runtime Error):
while True:
    n,m = map(int,raw_input().split())
    if n == 0 and m == 0:
        break

    amari = n % m
    yasai = map(int,raw_input().split())
    yasai.sort()

    s = 0
    if amari > 0:
        s = sum(yasai[0:amari])

    i = 0
    for y in yasai[amari:]:
        if i % m > 0:
            s += y
        i+=1

    print(s)

Fixed submission:
while True:
    try:
        n,m = list(map(int,input().split()))
        if n == 0 and m == 0:
            break
        amari = n % m
        yasai = list(map(int,input().split())) 
        yasai.sort()

        s = 0
        for i in range(n):
            if (i+1) % m > 0:
                s += yasai[-i-1]
        print(s)
    except:
        pass

Buggy python submission (verdict: Runtime Error):
while True:
    n,m = map(int,raw_input().split())
    if n == 0 and m == 0:
        break

    amari = n % m
    yasai = map(int,raw_input().split())
    yasai.sort()

    s = 0
    if amari > 0:
        s = sum(yasai[0:amari])

    i = 0
    for y in yasai[amari:]:
        if i % m > 0:
            s += y
        i+=1

    print(s)

Fixed submission:
while True:
    try:
        n,m = list(map(int,input().split()))
        if n == 0 and m == 0:
            break
        amari = n % m
        yasai = list(map(int,input().split())) 
        yasai.sort()

        s = 0
        for i in range(n):
            if (i+1) % m > 0:
                s += yasai[-i-1]
        print(s)
    except:
        pass

Buggy python submission (verdict: Runtime Error):
while True:
    n,m = map(int,raw_input().split())
   

Fixed submission:
while True:
    try:
        n,m = list(map(int,input().split()))
        if n == 0 and m == 0:
            break
        amari = n % m
        yasai = list(map(int,input().split())) 
        yasai.sort()

        s = 0
        for i in range(n):
            if (i+1) % m > 0:
                s += yasai[-i-1]
        print(s)
    except:
        pass

Buggy python submission (verdict: Runtime Error):
while True:
    n,m = map(int,raw_input().split(' '))

Fixed submission:
while True:
    try:
        n,m = list(map(int,input().split()))
        if n == 0 and m == 0:
            break
        amari = n % m
        yasai = list(map(int,input().split())) 
        yasai.sort()

        s = 0
        for i in range(n):
            if (i+1) % m > 0:
                s += yasai[-i-1]
        print(s)
    except:
        pass

Buggy python submission (verdict: Runtime Error):
while True:
    a = raw_input()
    print 'a'

Fixed submission:
while True:
    try:
        n,m = list(map(int,input().split()))
        if n == 0 and m == 0:
            break
        amari = n % m
        yasai = list(map(int,input().split())) 
        yasai.sort()

        s = 0
        for i in range(n):
            if (i+1) % m > 0:
                s += yasai[-i-1]
        print(s)
    except:
        pass

Buggy python submission (verdict: Runtime Error):
while True:
    a = input()
    print('a')

Fixed submission:
while True:
    try:
        n,m = list(map(int,input().split()))
        if n == 0 and m == 0:
            break
        amari = n % m
        yasai = list(map(int,input().split())) 
        yasai.sort()

        s = 0
        for i in range(n):
            if (i+1) % m > 0:
                s += yasai[-i-1]
        print(s)
    except:
        pass

Buggy python submission (verdict: Runtime Error):

while True:
    a = input()
    print('a')

Fixed submission:
while True:
    try:
        n,m = list(map(int,input().split()))
        if n == 0 and m == 0:
            break
        amari = n % m
        yasai = list(map(int,input().split())) 
        yasai.sort()

        s = 0
        for i in range(n):
            if (i+1) % m > 0:
                s += yasai[-i-1]
        print(s)
    except:
        pass