Language: C++

//
// Created by mustafa on 05/07/19.
//
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std ;

#define ll long long
#define submitStage int TCF = 1 ;
#define testStage int TCF = 1000 ;
#define Start while(TCF--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) FOR(i, 0, n)
#define FastInputOutput ios_base :: sync_with_stdio( 0 ) ; cin.tie( 0 ) ; cout.tie( 0 ) ;
#define ReadFromFile(x)  freopen( x, "rt" , stdin ) ;
#define WriteToFile(x)  freopen( "in.txt", "wt" , stdout ) ;
#define D(x) scanf("%d",&x);
#define LLD(X) scanf("%lld",&x);
#define in(x,...) scanf(x,__VA_ARGS__)
#define out(x,...) printf(x,__VA_ARGS__)
/// for debugging
string to_string(string s) {return '"' + s + '"';}string to_string(const char* s) {return to_string((string) s);}string to_string(bool b) {return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void debug_out() { cerr << endl; }template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) {cerr << " " << to_string(H);debug_out(T...);}
#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) {}
#endif
/// start driven program
const int N = 2e4+5, M = 1e4, OO = 0x3f3f3f3f;

int main(){
    submitStage Start{
        // 1 , 5 , 10;
        int n,y;
        scanf("%d %d",&n , &y);
        y/=1000;
        int mx10=y/10 , mx5=0 , mx1=0;
        int t10 =0 , t5 =0 , t1=0;
        int a10=-1,a5=-1,a1=-1;
        bool get=true;
        for(int i=0 ; i <= mx10 & get; ++i){
            t10=y- (i*10);
            mx5=t10/5;
            for(int j=0 ; j <= mx5 & get ; ++j){
                t5=t10-(j*5);
                mx1=t5;
                if(i+j+mx1==n){
                    a10=i;
                    a5=j;
                    a1=mx1;
                    get=false;
                }
            }

        }
        printf("%d %d %d",a10,a5,a1);

    }
}


//
// Created by mustafa on 05/07/19.
//
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std ;

#define ll long long
#define submitStage int TCF = 1 ;
#define testStage int TCF = 1000 ;
#define Start while(TCF--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) FOR(i, 0, n)
#define FastInputOutput ios_base :: sync_with_stdio( 0 ) ; cin.tie( 0 ) ; cout.tie( 0 ) ;
#define ReadFromFile(x)  freopen( x, "rt" , stdin ) ;
#define WriteToFile(x)  freopen( "in.txt", "wt" , stdout ) ;
#define D(x) scanf("%d",&x);
#define LLD(X) scanf("%lld",&x);
#define in(x,...) scanf(x,__VA_ARGS__)
#define out(x,...) printf(x,__VA_ARGS__)
/// for debugging
string to_string(string s) {return '"' + s + '"';}string to_string(const char* s) {return to_string((string) s);}string to_string(bool b) {return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void debug_out() { cerr << endl; }template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) {cerr << " " << to_string(H);debug_out(T...);}
#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) {}
#endif
/// start driven program
const int N = 2e4+5, M = 1e4, OO = 0x3f3f3f3f;

int main(){
    submitStage Start{
        // 1 , 5 , 10;
        int n,y;
        scanf("%d %d",&n , &y);
        y/=1000;
        int mx10=y/10 , mx5=0 , mx1=0;
        int t10 =0 , t5 =0 , t1=0;
        int a10=-1,a5=-1,a1=-1;
        bool get=true;
        for(int i=0 ; i <= mx10 & get; ++i){
            t10=y- (i*10);
            mx5=t10/5;
            for(int j=0 ; j <= mx5 & get ; ++j){
                t5=t10-(j*5);
                mx1=t5;
                if(i+j+mx1==n){
                    a10=i;
                    a5=j;
                    a1=mx1;
                    get=false;
                }
            }

        }
        printf("%d %d %d",a10,a5,a1);

    }
}




Compiler output:
a.cc:85:8: error: redefinition of 'std::string to_string(std::string)'
   85 | string to_string(string s) {return '"' + s + '"';}string to_string(const char* s) {return to_string((string) s);}string to_string(bool b) {return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void debug_out() { cerr << endl; }template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) {cerr << " " << to_string(H);debug_out(T...);}
      |        ^~~~~~~~~
a.cc:23:8: note: 'std::string to_string(std::string)' previously defined here
   23 | string to_string(string s) {return '"' + s + '"';}string to_string(const char* s) {return to_string((string) s);}string to_string(bool b) {return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void debug_out() { cerr << endl; }template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) {cerr << " " << to_string(H);debug_out(T...);}
      |        ^~~~~~~~~
a.cc:85:58: error: redefinition of 'std::string to_string(const char*)'
   85 | string to_string(string s) {return '"' + s + '"';}string to_string(const char* s) {return to_string((string) s);}string to_string(bool b) {return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void debug_out() { cerr << endl; }template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) {cerr << " " << to_string(H);debug_out(T...);}
      |                                                          ^~~~~~~~~
a.cc:23:58: note: 'std::string to_string(const char*)' previously defined here
   23 | string to_string(string s) {return '"' + s + '"';}string to_string(const char* s) {return to_string((string) s);}string to_string(bool b) {return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void debug_out() { cerr << endl; }template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) {cerr << " " << to_string(H);debug_out(T...);}
      |                                                          ^~~~~~~~~
a.cc:85:121: error: redefinition of 'std::string to_string(bool)'
   85 | string to_string(string s) {return '"' + s + '"';}string to_string(const char* s) {return to_string((string) s);}string to_string(bool b) {return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void debug_out() { cerr << endl; }template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) {cerr << " " << to_string(H);debug_out(T...);}
      |                                                                                                                         ^~~~~~~~~
a.cc:23:121: note: 'std::string to_string(bool)' previously defined here
   23 | string to_string(string s) {return '"' + s + '"';}string to_string(const char* s) {return to_string((string) s);}string to_string(bool b) {return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void debug_out() { cerr << endl; }template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) {cerr << " " << to_string(H);debug_out(T...);}
      |                                                                                                                         ^~~~~~~~~
a.cc:85:211: error: redefinition of 'template<class A, class B> std::string to_string(std::pair<_T1, _T2>)'
   85 | string to_string(string s) {return '"' + s + '"';}string to_string(const char* s) {return to_string((string) s);}string to_string(bool b) {return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void debug_out() { cerr << endl; }template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) {cerr << " " << to_string(H);debug_out(T...);}
      |                                                                                                                                                                                                                   ^~~~~~~~~
a.cc:23:211: note: 'template<class A, class B> std::string to_string(std::pair<_T1, _T2>)' previously declared here
   23 | string to_string(string s) {return '"' + s + '"';}string to_string(const char* s) {return to_string((string) s);}string to_string(bool b) {return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void debug_out() { cerr << endl; }template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) {cerr << " " << to_string(H);debug_out(T...);}
      |                                                                                                                                                                                                                   ^~~~~~~~~
a.cc:85:332: error: redefinition of 'template<class A> std::string to_string(A)'
   85 | string to_string(string s) {return '"' + s + '"';}string to_string(const char* s) {return to_string((string) s);}string to_string(bool b) {return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void debug_out() { cerr << endl; }template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) {cerr << " " << to_string(H);debug_out(T...);}
      |                                                                                                                                                                                                                                                                                                                                            ^~~~~~~~~
a.cc:23:332: note: 'template<class A> std::string to_string(A)' previously declared here
   23 | string to_string(string s) {return '"' + s + '"';}string to_string(const char* s) {return to_string((string) s);}string to_string(bool b) {return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void debug_out() { cerr << endl; }template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) {cerr << " " << to_string(H);debug_out(T...);}
      |                                                                                                                                                                                                                                                                                                                                            ^~~~~~~~~
a.cc:85:497: error: redefinition of 'void debug_out()'
   85 | string to_string(string s) {return '"' + s + '"';}string to_string(const char* s) {return to_string((string) s);}string to_string(bool b) {return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void debug_out() { cerr << endl; }template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) {cerr << " " << to_string(H);debug_out(T...);}
      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 ^~~