Go: package main

import (
	"bufio"
	"os"
	"strings"
	"strconv"
	"sort"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		buf := strings.Split(scanner.Text(), " ")
		n, _ := strconv.Atoi(buf[0])
		m, _ := strconv.Atoi(buf[1])
		if n == 0 && m == 0 {
			break
		}
		scanner.Scan()
		buf_ := strings.Split(scanner.Text(), " ")
		items := make([]int, n)
		for i := 0; i < n; i++ {
			items[i], _ = strconv.Atoi(buf_[i])
		}
		sort.Ints(items)
		sum := 0
		for _, v := range items {
			sum += v
		}
		for i := n-m; i >= 0; i -= m {
			sum -= items[i]
		}
		fmt.Println(sum)
	}
}

C++: #include<iostream>
using namespace std;

int main(){
  int n,m;
  while(1){
  int  ans=0,p[10001]={};
  cin>>n>>m;
  if(n+m==0)break;
  for(int i=1;i<=n;i++){
    cin>>p[i];
  }

  for(int j=0;j<n;j++)
    for(int i=1;i<=n;i++)
      if(p[i]<p[i+1])swap(p[i],p[i+1]);


  for(int i=1;i<=n;i++){
    if(i%m==0)p[i]=0;
    ans+=p[i];
  }


  cout<<ans<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>

using namespace std;

int main(){
	int data[1010];
	
	int n,m;
	while(cin>>n>>m && n &&m){
		for(int i=0;i<n;i++){
			cin>>data[i];
		}
		sort(data,data+n,greater<int>());
		int ans=0;
		for(int i=0;i<n;i++){
			int tmp=i;
			for(;i-tmp<m-1;i++){
				ans+=data[i];
			
			}

		}
		
		cout<<ans<<endl;
	}
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int n,m,a[1000];
main()
{
	while(cin>>n>>m,n)
	{
		int ans=0;
		for(int i=0;i<n;i++)
		{
			cin>>a[i];
			ans+=a[i];
		}
		sort(a,a+n);
		for(int i=n-m;i>=0i-=m)
		{
			ans-=a[i];
		}
		cout<<ans<<endl;
	}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
 
int main(){
	u_int n;	// the number of vegetable
	u_int m;	// capacity
	
	while(std::cin >> n >> m){
        if(n == 0 && m == 0){
            break;
        }
         
        std::vector<u_int> p(n);	// price
        for(int i = 0; i < n; ++i){
            std::cin >> p[i];
        }
        
        //m, 2*m, 3*m, ... = free(sort by descending)
        std::sort(p.begin(), p.end(), std::greater<u_int>());
        for(int i = m; i <= n; i += m){
            p[i-1] = 0;
        }
        
        std::cout << std::accumulate(p.begin(), p.end(), 0) << std::endl;
    }
     
    return 0;
}

C++: #include <iostream>
#include <queue>
#include <algorithm>

using namespace std;

int main(){
  int m,n,a,b,sum, temp;
  int ans;
  priority_queue<int> que;

  while(1) {
    sum = 0;
    cin>>n>>m;

    if(n == 0 && m == 0){
      break;
    }

    for(int i = 0; i<n; ++i){
      cin>>a;
      que.push(a);
    }

    for(int i = 1;i<=n;++i){
      b = que.top();
      que.pop();
      if(i % m != 0){
	sum += b;
      }
    }

    cout << sum << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>

int main(){
    int n, m, p, sum;
    std::vector<int> price_list = {};

    while(std::cin >> n >> m &&  (n != 0 || m != 0)){
        sum = 0;
        for(int i = 0;i < n;i++){
            std::cin >> p;
            price_list.push_back(p);
            sum += p;
        }
        std::sort(price_list.begin(), price_list.end(), std::greater<int>());
        for(int i = 1;i <= n/m;i++){
            sum -= price_list.at(i * m - 1);
        }
        std::cout << sum << std::endl;
    }
}

C++: #include<algorithm>
#include<iostream>
#include<vector>

int main()
{
	int n, m;
	while( std::cin >> n >> m, n | m )
	{
		std::vector<int> v( n );
		for( int i = 0; i != n; ++i )
		{
			int p;
			std::cin >> p;
			v.push_back( p );
		}
		
		std::sort( v.rbegin(), v.rend() );

		int ans = 0;
		for( int i = 0; i != n; ++i )
			if( ( i + 1 ) % m )
				ans += v[i];

		std::cout << ans << std::endl;
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>

int main(){
	int vnum, capacity;
	std::vector<int> vprice;

	while(std::cin >> vnum >> capacity){
		//end
		if(vnum == 0 && capacity == 0) break;

		int tmp,buf = capacity;
		int total = 0;
		std::vector<int> vprice;

		//input
		for(int i = 0; i < vnum; ++i){
			std::cin >> tmp;
			vprice.push_back(tmp);
		}

		//sort
		std::sort(vprice.begin(), vprice.end(), std::greater<int>());

		//sum price
		std::for_each(vprice.begin(),vprice.end(), 
			[&total,buf,&capacity](int x) { capacity != 1 ? (total += x, --capacity) : capacity = buf; } );

		//output
		std::cout << total << std::endl;
	}

	return 0;
}

C++: #include<cstdio>
#include<algorithm>
using namespace std;

int main(){
while(1){
int sina[1000],n,m,sum=0;
scanf("%d%d",&n,&m);
if(n==0&&m==0)return 0;
for(int i=0;i<n;i++){
scanf("%d",&sina[i]);
sum+=sina[i];
}
sort(sina,sina+n);
for(int i=n;i>=0;i-=m){
sum-=sina[i];
}
printf("%d\n",sum);
}
}

C++: #include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int main(int argc, char const* argv[])
{
	int n,m;
	int place[1000];

	while( cin >> n >> m && n != 0 ){
		for( int i = 0;i < 1000;i++ ) place[i] = 0;

		for( int i = 0;i < n;i++ ) cin >> place[i];
		sort( place, place + n, greater<int>() );

		for( int i = 1;i * m - 1 < n;i++ ) place[i * m - 1] = 0;
		
		int answer = 0;
		for( int i = 0;i < n;i++ ) answer += place[i];

		cout << answer << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>

int main(){
    int n, m, p, sum;
    std::vector<int> price_list = {};

    while(std::cin >> n >> m && (n != 0 && m != 0)){
        sum = 0;
        for(int i = 0;i < n;i++){
            std::cin >> p;
            price_list.push_back(p);
            sum += p;
        }
        std::sort(price_list.begin(), price_list.end(),std::greater<int>());
        for(int i = 1;i <= n/m;i++){
            sum -= price_list.at(i * m - 1);
        }
        std::cout << sum << std::endl;
    }
}

C++: #include <iostream>
#include <vector>
#include <string>

void swap(int *s, int *t){
    int tmp;
    tmp = *s;
    *s = *t;
    *t = tmp;
}

int main(){
    int n,m,x;
    int flag = 0;
    int num = 0;
    std::vector<int> v;
    
    std::cin >> n >> m;
    
    while(std::cin >> x){
        v.emplace_back(x);
    }
    
    //std::sort(v.rbegin(),v.rend());
    
    for(int i = 0;i < v.size();i++){
        for(int j = i+1;j < v.size();j++){
            if(v[i] < v[j]){
                swap(&v[i],&v[j]);
            }
        }
    }
    
    for(int y = 0;y < n;y++){
        flag++;
        if(flag != m){
            num += v[y];
        }
        else
             flag = 0;
    }
    std::cout << num << std::endl;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>

int main(){
    int n, m, p, sum;
    std::vector<int> price_list = {};

    while(std::cin >> n >> m && (n != 0 || m != 0)){
        sum = 0;
        for(int i = 0;i < n;i++){
            std::cin >> p;
            price_list.push_back(p);
            sum += p;
        }
        std::sort(price_list.begin(), price_list.end(), std::greater<int>());
        for(int i = 1;i <= n/m;i++){
            sum -= price_list.at(i * m - 1);
        }
        std::cout << sum << std::endl;
    }
}

C++: #include<iostream>
using namespace std;

main(){
  int m,n;
  int b[1001];
  while(cin >> n >> m,m || n){
    int total=0;
    int k=n/m;
    for(int i=0;i<n;i++) cin >> b[i];
    sort(b,b+n);

    for(int i=1;i<=n;i++){
      if(i%m) total+=b[n-i];
    }
    cout << total << endl;
  }
}