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 <stdio.h>
#include <stdlib.h>

int main(){
	int okane;
	int oturi;
	int count = 0;
	int a[] = { 1, 5, 10, 50, 100, 500 };

	scanf("%d", &okane);
	oturi = 1000 - okane;

	for (int i = 5; i >= 0; i--){
		if (oturi >= a[i]){
			div_t d;

			d = div(oturi, a[i]);
			oturi = oturi - a[i] * d.quot;
			count = count + d.quot;
		}
	}
	printf("%d\n",count);

	return 0;

}

C++: #include<iostream>

using namespace std; 

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

int main() {
    int n;
    int count = 0;
    while (cin >> n && n != 0) {
        n = 1000-n;
        for (int i = 0; i < 6; i++) {
            count += n/denominations[i];
            n -= denominations[i]*(n/denominations[i]);
        }
        cout << count << endl;
        count = 0; 
    }
}

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

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0521

int main() {
	int in;
	cin >> in;
	int p = 1000 - in;
	int ans = 0;
	int units[] = { 500, 100, 50, 10, 5, 1 };
	for (int i = 0; i < 6; i++) {
		ans += p /  units[i];
		p %= units[i];
	}
	cout << ans << endl;
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int a;
	int i;
	int s=0;
	
	cin>>a;
	a=1000-a;
	if(a>499){
		a=a-500;
		s=s+1;
	}
	for(i=0;i<4;i++){
		if(a>99){
			a=a-100;
			s=s+1;
		}
	}
	if(a>49){
		a=a-50;
		s=s+1;
	}
	for(i=0;i<4;i++){
		if(a>9){
			a=a-10;
			s=s+1;
		}
	}
	if(a>4){
		a=a-5;
		s++;
	}
	s=s+a;
	cout<<s<<endl;
}

C++: #include <iostream>
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;
return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
    int m,n,a,b,c,d,e,f,g;
    while(1){
        cin >> m;
        if(m==0){
            break;
        }
        a=1000-m;
        b=a/500;
        c=(a-500*b)/100;
        d=(a-500*b-100*c)/50;
        e=(a-500*b-100*c-50*d)/10;
        f=(a-500*b-100*c-50*d-e*10)/5;
        g=(a-500*b-100*c-50*d-e*10-f*5)/1;
        n=b+c+d+e+f+g;
        cout << n << endl;
    }
    
}

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

int main(){
    int N;
    while(cin>>N,N){
        int money[6]={500,100,50,10,5,1},ans=0;
        N=1000-N;
        for(int i=0;i<6;i++){
            while(N-money[i]>=0) N-=money[i],ans++;
        }
        printf("%d\n",ans);
    }
    return 0;
}

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

 
int main () 
{
  int m1;
  while(1)
  {
   cin>>m1; 
   if(m1<=0||m1>=1000)
   {
       break;
   }
   else
    {
    int m2,m3,m4,m5,m6,m7;

   m2=1000-m1;
   m3=m2/500;
   m4=m2%500/100;
   m5=m2%500%100/50;
   m6=m2%500%100%50/10;
   m7=m2%500%100%50%10/1;
  
   cout<<m3+m4+m5+m6+m7<<'\n';
   }
 }
   
  return 0;
}

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

int main(void)
{
    int ans;
    int change;
    int money;
    
    while (1){
        scanf("%d", &money);
        if (money == 0) break;
        
        ans = 0;
        change = 1000 - money;
        while (change != 0){
            if (500 <= change){
                change -= 500;
                ans++;
                continue;
            }
            if (100 <= change){
                change -= 100;
                ans++;
                continue;
            }
            if (50 <= change){
                change -= 50;
                ans++;
                continue;
            }
            if (10 <= change){
                change -= 10;
                ans++;
                continue;
            }
            if (5 <= change){
                change -= 5;
                ans++;
                continue;
            }
            if (1 <= change){
                change -= 1;
                ans++;
                continue;
            }
        }
        printf("%d\n", ans);
    }
    
    return (0);
}

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

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

int main(){
	for(;;){
		int N;
		cin >> N;
		if(N == 0) break;
		N = 1000 - N;
		int res = 0;
		for(int i = 0; i < 6; i++){
			int num = N / c[i];
			res += num;
			N -= c[i] * num;
		}
		cout << res << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
using namespace std;
int main()
{
	int a;
	cin >> a;
	int b;
	if (a >= 500)
	{
		a = a - 500;
		b++;
	}
	else if (a >= 100)
	{
		a = a - 100;
		b++;
	}
	else if (a >= 50)
	{
		a = a - 50;
		b++;
	}
	else if (a >= 10)
	{
		a = a - 10;
		b++;
	}
	else if (a >= 5)
	{
		a = a - 5;
		b++;
	}
	else if (a >= 1)
	{
		a = a - 1;
		b++;
	}
	else
	{
		cout << b << endl;
	}
	return 0;
}

C++: 

#include <iostream>
using namespace std;
int main(){
	while(true){

	int n,m;
	cin >> n;
	if(n == 0) return 0;
	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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const ll mod=998244353,MAX=200001,INF=1<<30;

int main(){
    
    while(1){
        int N;cin>>N;
        if(N==0) break;
    N=1000-N;
    int ans=0;
    if(N>=500){
        ans++;
        N-=500;
    }
    if(N>=100){
        ans+=N/100;
        N=N%100;
    }
    if(N>=50){
        ans++;
        N-=50;
    }
    if(N>=10){
        ans+=N/10;
        N=N%10;
    }
    if(N>=5){
        ans+=N/5;
        N=N%5;
    }
    ans+=N;
    
    cout<<ans<<endl;
    }
    
}

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

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

C++: #include <iostream>

using namespace std;

void solve()
{
	int p;
	while(cin >> p, p)
	{
		p = 1000 - p;
		int ans = 0;
		if(p >= 500)
		{
			p -= 500;
			++ans;
		}
		if(p >= 100)
		{
			int k = p / 100;
			p -= k * 100;
			ans += k;
		}
		if(p >= 50)
		{
			p -= 50;
			++ans;
		}
		if(p >= 10)
		{
			int k = p / 10;
			p -= k * 10;
			ans += k;
		}
		if(p >= 5)
		{
			p -= 5;
			++ans;
		}
		if(p >= 1)
		{
			ans += p;
		}
		cout << ans << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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