Go: package main

import "fmt"

func main() {
	var n, coins, change int
	for {
		fmt.Scan(&n)
		if n == 0 {
			return
		}
		coins = 0
		change = 1000 - n
		for change > 0 {
			coins++
			switch {
			case change >= 500:
				change -= 500
			case change < 500 && change >= 100:
				change -= 100
			case change < 100 && change >= 50:
				change -= 50
			case change < 50 && change >= 10:
				change -= 10
			case change < 10 && change >= 5:
				change -= 5
			default:
				change--
			}
		}
		fmt.Println(coins)
	}
}

Python: while True:
    n = int(input())
    charge = 1000 - n
    
    if n == 0:
        break

    count_coin = 0
    coin_kind =[1,5,10,50,100,500]

    for i in range(1,7):
        t = charge // coin_kind[-i]
        charge -= t * coin_kind[-i]
        count_coin += t

    print(count_coin)

Python: coin=[500,100,50,10,5,1]
while True:
	a = 1000-int(input())
	if a == 1000: break
	ans = 0
	for i in coin:
		ans += a // i
		a %= i 
	print(ans)

Python: price=int(input())
while price!=0:
    change=1000-price
    if change//500==1:
        fiveh=1
        change-=500
    else:
        fiveh=0
    if change//100>0:
        hundred=change//100
        change=change%100
    else:
        hundred=0
    if change//50>0:
        fifty=change//50
        change=change%50
    else:
        fifty=0
    if change//10:
        ten=change//10
        change=change%10
    else:
        ten=0
    if change//5:
        five=change//5
        change=change%5
    else:
        five=0
    one=change    
    print(fiveh+hundred+fifty+ten+five+one)  
    price=int(input())
else:
    pass

Python: while True:
    a = int(input())
    if a == 0:break

    A = [500,100,50,10,5,1]
    a= 1000 - a
    ans = 0
    for b in A:
        ans+=a // b
        a%=b
    print(ans)

Python: a,b=1,0
while a>0:
    a=int(input())
    if a==0:
        break
    b=1000-a
    c=b//500
    d=b%500//100
    e=b%100//50
    f=b%50//10
    g=b%10//5
    h=b%5
    print(c+d+e+f+g+h)

Python: coin = [500,100,50,10,5,1]
while True:
 x = int(input())
 change = 1000-x
 if x == 0:break
 else:
     ans = 0
     for i in coin:
         ans += change // i
         change %= i
     print(ans)

Python: taro_spend = []
spend_num = 0

for i in range(5):
    taro_spend.append(int(input()))
    if taro_spend[i] == 0:
        taro_spend.pop()
        break
    spend_num += 1

changes = [1000 - taro_spend[i] for i in range(spend_num)]

for change in changes:
    change_coin = 0

    if change >= 500:
        change -= 500
        change_coin += 1

    if change >= 100:
        while change >= 100:
            change -= 100
            change_coin += 1
            
    if change >= 50:
        change -= 50
        change_coin += 1
        
    if change >= 10:
        while change >= 10:
            change -= 10
            change_coin += 1

    if change >= 5:
        change -= 5
        change_coin += 1

    if change >= 1:
        while change >= 1:
            change -= 1
            change_coin += 1

    print(change_coin)

Python: while True:
    n = int(input())
    if n == 0:
        break
    oturi = 1000 - n
    li = [500,100,50,10,5,1]
    cnt = [0,0,0,0,0,0]
    for i in range(len(li)):
        cnt[i] = oturi//li[i]
        oturi -= cnt[i]*li[i]
    ans = 0
    for i in range(len(cnt)):
        ans += cnt[i]
    print(ans)

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	while (1) {

		int N; cin >> N;
		N = 1000 - N;
		int ans = 0;
		set<int>s;
		s = { 500,100,50,10,5,1 };
		for (auto m : s) {
			ans += N / m;
			N /= m;
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include <stdio.h>

int N;
int coin[6] = { 500,100,50,10,5,1 };
int ans = 0;

int main(void) {
	while (true) {
		scanf("%d", &N);
		if (N == 0) { break; }

		int res = 1000 - N;
		while (res != 0) {
			if (res >= 500) {
				ans += res / 500;
				res -= 500 * (res / 500);
			}
			else if (res >= 100) {
				ans += res / 100;
				res -= 100 * (res / 100);
			}
			else if (res >= 50) {
				ans += res / 50;
				res -= 50 * (res / 50);
			}
			else if (res >= 10) {
				ans += res / 10;
				res -= 10 * (res / 10);
			}
			else if (res >= 5) {
				ans += res / 5;
				res -= 5 * (res / 5);
			}
			else { ans += res; res = 0; }
		}
		printf("%d\n", ans);
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int n ,coin=0;
  while ( 1 ){
    cin >> n;
    if( n == 0 ){
      break;
    }
 
    n = 1000 - n; 
    
    if( n >= 500 ){
      while( n >= 500 ){
	n -= 500;
	coin++;
      }
    }
    
    if( n >= 100 ){
      while( n >= 100 ){
	n -= 100;
	coin++;
      }
    }
  
    if( n >= 50 ){
      while( n >= 50 ){
	n -= 50;
	coin++;
	cout << "50"  << endl;
      }
    }
    
    if( n >= 10 ){
      while( n >= 10 ){
	n -= 10;
	coin++;
      }
    }
    
    if( n >= 5 ){
      while( n >= 5 ){
	n -= 5;
	coin++;
      }
    }
    
    if( n >= 1 ){
      while( n >= 1 ){
	n -= 1;
	coin++;
      }
    }
    
    cout << coin << endl;
    coin = 0;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main() {

  int value,change;
  int coins;


  while(1) {

    cin >> value;

    if(value==0) break;

    coins=0;
    change=1000-value;

    coins+=change/500;
    change%=500;

    coins+=change/100;
    change%=100;

    coins+=change/50;
    change%=50;

    coins+=change/10;
    change%=10;

    coins+=change/5;
    change%=5;

    coins+=change/1;
    change%=1;

    cout << coinsツ　<< endl;

  }

  return 0;

}

C++: #include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>

using namespace std;


int combart(int a) {
	int maisuu = 0;
	if (a >= 5) {
		maisuu++;
		a -= 5;
	}
	return maisuu + a;
}

int main(){

	int siharai;
	int oturi;

	while (1) {
		cin >> siharai;
		if (siharai == 0)break;

		oturi = 1000 - siharai;

		int hyaku = oturi / 100;
		int juu = (oturi % 100) / 10;
		int iti = oturi % 10;

		cout << combart(hyaku) + combart(juu) + combart(iti) << endl;
	}


//	system("pause");
    return 0;
}

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


int main(){
    while (1){
	int n;
	
	int m = 0;
	cin >> n;
	if (n == 0) break;
	n = 1000 - n;
	
	while (n >= 500){
	    m++;
	    n -= 500;
	    cout << n << " " << m << endl;
	}
	while (n >= 100){
	    m++;
	    n -= 100;
	    cout << n << " " << m << endl;
	}
	while (n >= 50){
	    m++;
	    n -= 50;
	    cout << n << " " << m << endl;
	}
	while (n >= 10){
	    m++;
	    n -= 10;
	    cout << n << " " << m << endl;
	}
	while (n >= 5){
	    m++;
	    n -= 5;
	    cout << n << " " << m << endl;
	}
	while (n >= 1){
	    m++;
	    n -= 1;
	}

	cout << m << endl;
    
    }
}

C++: main(){
int money = 1000;int buy = 0;int maisuu = 0;
cin >> buy;
money = money - buy;
if(money >= 500){
 	maisuu = maisuu + 1;
 	money = money - 500 ;
 }
if(money >= 100){
 	maisuu = maisuu + money/100;
 	money =money % 100;
  }
if(money >= 50){
 	maisuu = maisuu + 1;
 	money = money - 50 ;
 }
if(money >= 100){
 	maisuu = maisuu + money/10;
 	money =money % 10;
  }
money = money - buy
if(money >= 5){
 	maisuu = maisuu + 1;
 	money = money - 5 ;
 }
maisuu = maisuu + money;
cout << maisuu << endl;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
p=1000,s=0;
  p-=n;
  s+=p/500;
  p%=500;
  s+=p/100;
  p%=100;
  s+=p/50;
  p%=50;
  s+=p/10;
  p%=10;
  s+=p/5;
  p%=5;
  s+=p/1;
  p%=1;
  cout<<s<<endl;}

}