Language: C++

#include<iostream>
#include<string>
#include<vector>

#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

int main(void) {
	int temp = 0;
	int cost_input[10];
	int cost_return = 0;
	int num = 0;
	int j = 0;

	for (int i = 0; i < 10; ++i) {
		CI temp;
		if (temp == 0) {
			j = i;
			break;
		}
		cost_input[i] = temp;

		cost_return = 1000 - cost_input[i];
		num = 0;

		if (cost_return < 5) {
			num = cost_return;
			break;
		}
		else {
			if (cost_return < 10) {
				num = 1 + cost_return - 5;
			}
			/*else {
				if (cost_return < 100) {
					num += (cost_return / 10);
					if (cost_return % 10 < 5) {
						num += cost_return % 10
					}
					else {
						num += 1 + cost_return - 5;
					}
				}
				else
				{
					if (cost_return < 500) {
						num += (cost_return / 100);
						if (cost_return % 100 < 5) {
							num += cost_return % 10
						}
						else {
							num += 1 + cost_return - 5;
						}
					}
				}
			}*/
		}
		if (cost_return >= 500) {
			++num_answer;
			cost_return -= 500;
		}
		while (1) {
			if (cost_return >= 100) {
				++num_answer;
				cost_return -= 100;
			}
			if (cost_return < 100)break;
		}
		if (cost_return >= 50) {
			++num_answer;
			cost_return -= 50;
		}
		while (1) {
			if (cost_return >= 10) {
				++num_answer;
				cost_return -= 10;
				if (cost_return < 10)break;
			}
		}

		if (cost_return >= 5) {
			++num_answer;
			cost_return -= 5;
		}
		while (1) {
			if (cost_return >= 1) {
				++num_answer;
				cost_return -= 1;
			}
			if (cost_return < 1)break;
		}
		/*if (cost_return >= 500) {
			++num_answer;
			cost_return -= 500;
		}
		while (1) {
			if (cost_return >= 100) {
				++num_answer;
				cost_return -= 100;
			}
			if (cost_return < 100)break;
		}
		if (cost_return >= 50) {
			++num_answer;
			cost_return -= 50;
		}
		while (1){
			if (cost_return >= 10) {
				++num_answer;
				cost_return -= 10;
				if (cost_return < 10)break;
			}
		}

		if (cost_return >= 5) {
			++num_answer;
			cost_return -= 5;
		}
		while (1) {
			if (cost_return >= 1) {
				++num_answer;
				cost_return -= 1;
			}
			if (cost_return < 1)break;
		}*/
	}
	

	for (int i = 0; i < j;++i) {
		CO num_answer E
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:62:27: error: 'num_answer' was not declared in this scope
   62 |                         ++num_answer;
      |                           ^~~~~~~~~~
a.cc:67:35: error: 'num_answer' was not declared in this scope
   67 |                                 ++num_answer;
      |                                   ^~~~~~~~~~
a.cc:73:27: error: 'num_answer' was not declared in this scope
   73 |                         ++num_answer;
      |                           ^~~~~~~~~~
a.cc:78:35: error: 'num_answer' was not declared in this scope
   78 |                                 ++num_answer;
      |                                   ^~~~~~~~~~
a.cc:85:27: error: 'num_answer' was not declared in this scope
   85 |                         ++num_answer;
      |                           ^~~~~~~~~~
a.cc:90:35: error: 'num_answer' was not declared in this scope
   90 |                                 ++num_answer;
      |                                   ^~~~~~~~~~
a.cc:133:20: error: 'num_answer' was not declared in this scope
  133 |                 CO num_answer E
      |                    ^~~~~~~~~~