Language: C++

#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
ll n,m,v,i,y,cnt=0,ans=0;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>y;
  if(y%5000 == 1000) cnt = 1;
  else if(y%5000 == 2000) cnt = 2;
  else if(y%5000 == 3000) cnt = 3;
  else if(y%5000 == 4000) cnt = 4;
  else  cnt = 0;
  ll y_temp = y;
  while(1){
    // cout<<cnt<<endl;
    y = y_temp;
    y -= cnt * 1000;
    if(y<=0) {
      cout<<-1<<" "<<-1<<" "<<-1<<endl;
      break;
    }
    ll p = y/5000;
    if(p%2==0){
      if(p/2 + cnt <= n && p+cnt >= n){
         // cout<<cnt<<" "<<p - 2 * (p+cnt - n)<<" "<<(p+cnt - n)<<endl;
        cout<<(p+cnt - n)<<" "<<p - 2 * (p+cnt - n)<<" "<<cnt<<endl;
        break;
      }
    } else {
      if(p/2 + 1 + cnt <= n && p+cnt >= n){
        cout<<(p+cnt - n)<<" "<<p - 2 * (p+cnt - n)<<" "<<cnt<<endl;
        break;
      }
    }
    cnt+=5;
  }

}

int main(){
  solve();
  return 0;
}
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
ll n,m,v,i,y,cnt=0,ans=0;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>y;
  if(y%5000 == 1000) cnt = 1;
  else if(y%5000 == 2000) cnt = 2;
  else if(y%5000 == 3000) cnt = 3;
  else if(y%5000 == 4000) cnt = 4;
  else  cnt = 0;
  ll y_temp = y;
  while(1){
    // cout<<cnt<<endl;
    y = y_temp;
    y -= cnt * 1000;
    if(y<=0) {
      cout<<-1<<" "<<-1<<" "<<-1<<endl;
      break;
    }
    ll p = y/5000;
    if(p%2==0){
      if(p/2 + cnt <= n && p+cnt >= n){
         // cout<<cnt<<" "<<p - 2 * (p+cnt - n)<<" "<<(p+cnt - n)<<endl;
        cout<<(p+cnt - n)<<" "<<p - 2 * (p+cnt - n)<<" "<<cnt<<endl;
        break;
      }
    } else {
      if(p/2 + 1 + cnt <= n && p+cnt >= n){
        cout<<(p+cnt - n)<<" "<<p - 2 * (p+cnt - n)<<" "<<cnt<<endl;
        break;
      }
    }
    cnt+=5;
  }

}

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


Compiler output:
a.cc:251:38: error: redefinition of 'template<class T, class U> void chmin(T&, U)'
  251 | template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
      |                                      ^~~~~
a.cc:99:38: note: 'template<class T, class U> void chmin(T&, U)' previously declared here
   99 | template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
      |                                      ^~~~~
a.cc:252:38: error: redefinition of 'template<class T, class U> void chmax(T&, U)'
  252 | template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
      |                                      ^~~~~
a.cc:100:38: note: 'template<class T, class U> void chmax(T&, U)' previously declared here
  100 | template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
      |                                      ^~~~~
a.cc:264:4: error: redefinition of 'll n'
  264 | ll n,m,v,i,y,cnt=0,ans=0;
      |    ^
a.cc:112:4: note: 'll n' previously declared here
  112 | ll n,m,v,i,y,cnt=0,ans=0;
      |    ^
a.cc:264:6: error: redefinition of 'll m'
  264 | ll n,m,v,i,y,cnt=0,ans=0;
      |      ^
a.cc:112:6: note: 'll m' previously declared here
  112 | ll n,m,v,i,y,cnt=0,ans=0;
      |      ^
a.cc:264:8: error: redefinition of 'll v'
  264 | ll n,m,v,i,y,cnt=0,ans=0;
      |        ^
a.cc:112:8: note: 'll v' previously declared here
  112 | ll n,m,v,i,y,cnt=0,ans=0;
      |        ^
a.cc:264:10: error: redefinition of 'll i'
  264 | ll n,m,v,i,y,cnt=0,ans=0;
      |          ^
a.cc:112:10: note: 'll i' previously declared here
  112 | ll n,m,v,i,y,cnt=0,ans=0;
      |          ^
a.cc:264:12: error: redefinition of 'll y'
  264 | ll n,m,v,i,y,cnt=0,ans=0;
      |            ^
a.cc:112:12: note: 'll y' previously declared here
  112 | ll n,m,v,i,y,cnt=0,ans=0;
      |            ^
a.cc:264:14: error: redefinition of 'll cnt'
  264 | ll n,m,v,i,y,cnt=0,ans=0;
      |              ^~~
a.cc:112:14: note: 'll cnt' previously defined here
  112 | ll n,m,v,i,y,cnt=0,ans=0;
      |              ^~~
a.cc:264:20: error: redefinition of 'll ans'
  264 | ll n,m,v,i,y,cnt=0,ans=0;
      |                    ^~~
a.cc:112:20: note: 'll ans' previously defined here
  112 | ll n,m,v,i,y,cnt=0,ans=0;
      |                    ^~~
a.cc:265:6: error: redefinition of 'void solve()'
  265 | void solve(){
      |      ^~~~~
a.cc:113:6: note: 'void solve()' previously defined here
  113 | void solve(){
      |      ^~~~~
a.cc:301:5: error: redefinition of 'int main()'
  301 | int main(){
      |     ^~~~
a.cc:149:5: note: 'int main()' previously defined here
  149 | int main(){
      |     ^~~~