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)
	}
}

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

int c[6] = {500,100,50,10,5,1};

int main(){

	//int c[6] = {500,100,50,10,5,1};
	int money, pay, change;

	scanf("%d", &pay);

	change = 0;
	money = 1000 - pay;

	for(int i = 0; i < 6; i++){

		change += money / c[i];
		money = money % c[i];
	}

	if(pay != 0) printf("%d\n", change);

	
	return 0;
}

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

int main() {

	//ifstream cin("INPUT.txt");
	//ofstream cout("OUTPUT.txt");

	int s, o;
	while(cin >> s, s) {
		s = 1000 - s;
		o = 0;
		while(s >= 500) {
			s -= 500;
			o++;
		}
		while(s >= 100){
			s -= 100;
			o++;
		}
		while(s >= 50){
			s -= 50;
			o++;
		}
		while(s >= 10){
			s -= 10;
			o++;
		}
		while(s >= 5){
			s -= 5;
			o++;
		}
		o += s;
		cout << o << endl;
	}

	return 0;

}

C++: #include<iostream>
using namespace std;
int t[]={500,100,50,10,5,1};
int main(){
  while(1){
    int n,ans=0;
    cin>>n;
    if(n==0)break;
    n=1000-n;
    for(int i=0;i<6;i++)ans+=n/t[i],n%=t[i];
    cout<<ans<<endl;
  }
  return 0;
}

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

int main(int argc, char const *argv[]){
    int n;
    const int m[6] = {500, 100, 50, 10, 5, 1};

    while (cin>>n, n){
        int ans = 0;
        int ret = 1000 - n;
        for (int i = 0; i < 6; i++){
            int t = ret / m[i];
            ret -= t * m[i];
            ans += t;
        }

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

C++: #include<iostream>
#include<algorithm>
using namespace std;
#define INF ( 1 << 30 )

int dp[1001],tmp[]={500,100,50,10,5,1},n;
int main(){
  fill_n(dp,1001,INF);
  dp[0] = 0;
  for(int i = 0 ; i < 1001 ; i++ ){
    for(int j = 0 ; j < 6 ; j++ ){
      if(i-tmp[j]>=0) dp[i] = min(dp[i],dp[i-tmp[j]]+1);
    }
  }
  while(cin >> n , n) cout << dp[1000-n] << endl;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n,m;
	cin >> n;
	m = 0;
	n = 1000-n;

	if(n>=500){
		m = n/500;
		n = n%500;
	}
	if(n>=100){
		m = m+n/100;
		n = n%100;
	}
	if(n>=50){
		m = m+n/50;
		n = n%50;
	}
	if(n>=10){
		m = m+n/10;
		n = n%10;
	}
	if(n>=5){
		m = m+n/5;
		n = n%5;
	}
	if(n>=1){
		m = m+n/1;
	}

	cout << m << endl;

}

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

C++: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int ot(int m) {
	return m / 5 + m % 5;
}
int main() {
	int m;
	cin >> m;
	while (m != 0) {
		m = 1000 - m;
		int ans = 0;
		for (int i = 0; i < 4; i++) {
			int l = m % 10;
			ans += ot(l);
			m = m / 10;
		}
		cout << ans << endl;
		cin >> m;
	}
	return 0;
}

C++: #include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  int m[6] = {500, 100, 50, 10, 5, 1};
  int n;
  cin >> n;
  n = 1000 - n;
  int ans = 0;
  while(n > 0) {
    FOR(i,0,6) {
      if(n >= m[i]) {
        ans++;
        n -= m[i];
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
  int money,oturi,maisu = 0;
  
  cin >> money;
  oturi = 1000 - money;
  for(int i = 1000;oturi > 10;i /= 10){
    oturi %= i;
    if(oturi >= i/10){
      (oturi / (i/10) >= 5) ? (maisu += oturi / (i/10) - 4) : (maisu += oturi / (i/10));
    }
  }
  cout << maisu << endl;
    
    return 0;
  }

C++: #include<iostream>
using namespace std;
int t[] = {500,100,50,10,5,1};
int main(void){
    while(true){
        int n,count = 0;
        cin >> n;
        if(n == 0)break;
        n = 1000 - n;
        for(int i=0; i<6; i++){
            count+=n/t[i];
            n%=t[i];
        }
        cout<<count<<endl;
    }
}

C++: #include<iostream>
using namespace std;
int main() {
	int a, b[] = { 500,100,50,10,5,1 }, ruio = 0;
	cin >> a;
	while (a != 0) {
		a = 1000 - a;
		for (int i = 0; i < 5; i++) {
			ruio += a / b[i];
			a = a%b[i];
		}
		cout << ruio+a << endl;
		cin >> a;
		ruio = 0;
	}
}

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

int main(){
  int m;
  while(cin >> m,m){
    int c=0;
    m=1000-m;
	while(m-500>=0){
	  m=m-500;
	  c++;
	}
	while(m-100>=0){
	  m=m-100;
	  c++;
	}
	while(m-50>=0){
	  m=m-50;
	  c++;
	}
	while(m-10>=0){
	  m=m-10;
	  c++;
	}
	while(m-5>=0){
	  m=m-5;
	  c++;
	}
	while(m-1>=0){
	  m=m-1;
	  c++;
	}
	cout << c << endl;
  }
  return 0;
}

C++: #include <cstdio>
using namespace std;
const int coin[] = {500,100,50,10,5,1};
int main() {
	int n;
	while (scanf("%d",&n)&&n!=0) {
		int res=0,turi=1000-n,m=0;
		while (turi!=0) {
			if (turi<coin[m]) {
				m++;
			} else {
				turi -= coin[m];
				res++;
			}
		}
		printf("%d\n",res);
	}
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <queue>
#include <utility>
using namespace std;
int main() {
	int N;
	int C[]={500,100,50,10,5,1};
	while(scanf("%d",&N),N) {
		N=1000-N;
		int sum=0;
		for(int i=0;i<6;i++) {
			sum+=N/C[i];
			N%=C[i];
		}
		printf("%d\n",sum);
	}
}

C++: #include<bits/stdc++.h>
using namespace std;

int main(){
  int n;
  while(cin>>n,n!=0){
    n = 1000-n;
    const vector<int> list = {500,100,50,10,5,1};
    int ans = 0;
    for(int i=0;i<list.size();i++){
      ans += n / list[i];
      n = n % list[i];
    }
    cout<<ans<<endl;
  }
}

C++: #include<iostream>
using namespace std;
int main(){
	int cut=0;
	int a;
	int b;
	while(1){
	cin>>a;
		cut=0;
		if(a==0){
			break;
		}
	b=1000-a;
	cut+=b/500;
	b=b%500;
	cut+=b/100;
	b=b%100;
	cut+=b/50;
	b=b%50;
	cut+=b/10;
	b=b%10;
	cut+=b/5;
	b=b%5;
	cut+=b;
	cout<<cut<<endl;
	}
	return 0;
}

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

C++: #include <iostream>
using namespace std;
int main(void){
    // Here your code !
    int n = 1;
    int pay ;

    
    while (n){
        int cent = 0;
        
        cin >>n;
        if (n==0){
            break;
        }
    

    
    pay = 1000 - n;
    
    if (pay >= 500){
        pay -= 500;
        cent++;
    }
    
    while (pay >= 100){
        pay -= 100;
        cent++;
    }
    
    while (pay >= 50){
        pay -= 50;
        cent++;
    }
    
    while (pay >= 10){
        pay -= 10;
        cent++;
    }
    
    while (pay >= 5){
        pay -= 5;
        cent++;
    }
    
    while (pay >= 1){
        pay -= 1;
        cent++;
    }
    
    cout << cent << "\n";
 
    
    }
    return 0;

}