Language: C++

#include <bits/stdc++.h>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int t;
int coin[4]={10,50,100,500};
int num[4];
int res[4];

int cmin=inf;
int index[4];

void dfs(int i){
	if(i==4){
		int sum=0;
		rep(j,4) sum+=coin[j]*index[j];
		if(sum<t)
			return;
		sum-=t;
		int ch[4];
		rep(j,4){
			ch[3-j]=sum/coin[3-j];
			sum-=(sum/coin[3-j]*coin[3-j]);
		}
		int cur=0;
		rep(j,4) cur+=(num[j]-index[j]+ch[j]);
		if(cur<cmin){
			cmin=cur;
			rep(j,4) res[j]=index[j];
		}
		return;
	}
	for(index[i]=0;index[i]<=num[i];++index[i]){
		dfs(i+1);
	}
	return ;
}

int main(void){
	bool first=true;
	while(cin >> t){
		if(t==0)
			break;
		if(first)
			first=false;
		else
			cout << endl;
		cmin=inf;
		rep(i,4) cin >> num[i];
		dfs(0);
		rep(i,4)if(res[i]!=0)
			cout << coin[i] <<" " << res[i] << endl;
	}
	return 0;
}

Compiler output:
a.cc:38:12: error: 'int index [4]' redeclared as different kind of entity
   38 | int index[4];
      |            ^
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'void dfs(int)':
a.cc:43:44: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   43 |                 rep(j,4) sum+=coin[j]*index[j];
      |                                            ^
a.cc:53:44: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   53 |                 rep(j,4) cur+=(num[j]-index[j]+ch[j]);
      |                                            ^
a.cc:56:46: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   56 |                         rep(j,4) res[j]=index[j];
      |                                              ^
a.cc:60:18: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   60 |         for(index[i]=0;index[i]<=num[i];++index[i]){
      |                  ^
a.cc:60:29: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   60 |         for(index[i]=0;index[i]<=num[i];++index[i]){
      |                             ^
a.cc:60:48: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   60 |         for(index[i]=0;index[i]<=num[i];++index[i]){
      |                                                ^