Go: ///
// File:  0521.go
// Author: ymiyamoto
//
// Created on Wed Mar  7 22:11:28 2018
//
package main

import (
	"fmt"
)

var money int

func main() {
	for {
		fmt.Scan(&money)
		if money == 0 {
			break
		}
		rem := 1000 - money

		count := 0
		for _, coin := range []int{500, 100, 50, 10, 5, 1} {
			count += rem / coin
			rem %= coin
		}
		fmt.Println(count)
	}
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main(){
	int n;
	while(cin >> n, n){
		int change = 1000 - n;
		int ans = 0;
		ans += change/500;
		change %= 500;
		ans += change/100;
		change %= 100;
		ans += change/50;
		change %= 50;
		ans += change/10;
		change %= 10;
		ans += change/5;
		change %= 5;
		ans += change;
		cout << ans << endl;
	}
	return 0;
}

C++: #include <stdio.h>
#include <vector>
#include <algorithm>
#include <stack>
 
using namespace std;
 
 
int main(){
 
    int coin[6] ={ 500,100,50,10,5,1 },sum,price;
 
    while(true){
        scanf("%d",&price);
        if(price == 0)break;
 
        sum = 0;
 
        price = 1000 - price;
 
        for(int i = 0; i <= 5; i++){
            while(price >= coin[i]){
                price -= coin[i];
                sum++;
            }
        }
 
        printf("%d\n",sum);
    }
 
    return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
  int money,count,maisu = 0,oturi[1000] = {};
  int money2[6] = {500,100,50,10,5,1};

  for(int i = 0;i >= 0;i++){
    cin >> money;
    count++;
    if(money == 0)
      break;
    oturi[i] = 1000 - money;
  }

  for(int j = 0;j < count;j++){ 
    for(int i = 0;i < 6;i++){
      maisu += oturi[j] / money2[i];
      oturi[j] %= money2[i];
    }
  }
  cout << maisu << endl;
    
    return 0;
  }

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

//????¬??????§?????£???????????°????±???????
int coin(int X){
    int ans = 0;
    //500
    ans = X / 500;

    //100
    ans = ans + (X % 500) / 100;

    //50
    ans = ans + ((X % 500) % 100) / 50;

    //10
    ans = ans + (((X % 500) % 100) % 50) / 10;

    //5
    ans = ans + ((((X % 500) % 100) % 50) % 10) / 5;

    //1
    ans = ans + (((((X % 500) % 100) % 50) % 10) % 5);

    return  ans;
}

int main(void){

    int i = 0;
    int ans[5];
    int input;
    while(1){
        cin >> input;
        if(input == 0){ break;}
        else{
            ans[i] = coin(1000-input);
        }
        i++;
    }

    for(int j = 0; j < i; j++){
        cout << ans[j] << endl;
    }

    return 0;
}

C++: 






 


Beta 




 
 paiza.IO 


 ??°????????????  


?????§


???????????????


 ??\??¬???   






 
???????????¢?????? 

?????°?????? 

???  





 

























































 





C++   Split Button!   

   

 
 Main.cpp   ???  

 
+ 


 
 

 Success 



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47







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











 


??± ?????? (Ctrl-Enter)    Split Button!   












   ???     ???   ???   ??£   
   
 
???  
 

 
??? ??? ???   
 
???  
 ???    



 ?????? 








 ??\???  


 ???????????? 0  

(0.00 sec)  

 
TextHTMLJSON ???  


3
15
4















 








 



















 







































































  

SumoMe

































































 


Beta 




 
 paiza.IO 


 ??°????????????  


?????§


???????????????


 ??\??¬???   






 
???????????¢?????? 

?????°?????? 

???  





 

























































 





C++   Split Button!   

   

 
 Main.cpp   ???  

 
+ 


 
 

 Success 



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47







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











 


??± ?????? (Ctrl-Enter)    Split Button!   












   ???     ???   ???   ??£   
   
 
???  
 

 
??? ??? ???   
 
???  
 ???    



 ?????? 








 ??\???  


 ???????????? 0  

(0.00 sec)  

 
TextHTMLJSON ???  


3
15
4















 








 



















 







































































  

SumoMe




















 


Beta 




 
 paiza.IO 


 ??°????????????  


?????§


???????????????


 ??\??¬???   






 
???????????¢?????? 

?????°?????? 

???  





 

























































 





C++   Split Button!   

   

 
 Main.cpp   ???  

 
+ 


 
 

 Success 



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47







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











 


??± ?????? (Ctrl-Enter)    Split Button!   












   ???     ???   ???   ??£   
   
 
???  
 

 
??? ??? ???   
 
???  
 ???    



 ?????? 








 ??\???  


 ???????????? 0  

(0.00 sec)  

 
TextHTMLJSON ???  


3
15
4















 








 



















 







































































  

SumoMe








































#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;

}

C++: #include<iostream>
#define shiharai 1000
using namespace std;
int main(){
    while(1){
        const int Zeni[6] = {500,100,50,10,5,1};
        int daikin = 0;
        int otsuri = 0;
        int Ozeni = 0;
        int i = 0;
        cin >> daikin;
        if(daikin == 0){
            break;
        }
        otsuri = shiharai - daikin;
        while(i < 6){
            while(otsuri >= Zeni[i]){
                Ozeni++;
                otsuri-=Zeni[i];
            }
            i++;
        }
        cout << Ozeni << endl;
    }
    return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int x,y;
	
	while(1){
		scanf("%d",&x);
		if(x==0) break;
		y=0;
		x=1000-x;
		while(1){
			if(x<1) break;
			if(x>=500){
				x=x-500; y++;
			}
			else if(x>=100){
				x=x-100; y++;
			}
			else if(x>=50){
				x=x-50; y++;
			}
			else if(x>=10){
				x=x-10; y++;
			}
			else if(x>=5){
				x=x-5; y++;
			}
			else{
				x=x-1; y++;
			}
		}
		printf("%d\n",y);
	}
	return 0;
}

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

int kouka[6] = { 500,100,50,10,5,1 };
int main() {
	int a;
	while (cin >> a, a) {
		a = 1000 - a;
		int sum = 0;
		for (int b = 0; b < 6; b++) {
			sum += a / kouka[b];
			a -= a / kouka[b] * kouka[b];
		}
		cout << sum << endl;
	}
}