Language: C++

#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll unsigned long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

void solve() {
    int x;
    cin >> x;
    int a = x/500;
    int b = (x%500)/5;
    cout << a*1000 + 5*b;
    
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int t = 1;
    // cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll unsigned long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

void solve() {
    int x;
    cin >> x;
    int a = x/500;
    int b = (x%500)/5;
    cout << a*1000 + 5*b;
    
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int t = 1;
    // cin >> t;
    while(t--) {
      solve();
    }
    return 0;
}


Compiler output:
a.cc:96:12: error: redefinition of 'std::mt19937_64 rang'
   96 | mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
      |            ^~~~
a.cc:32:12: note: 'std::mt19937_64 rang' previously declared here
   32 | mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
      |            ^~~~
a.cc:97:5: error: redefinition of 'int rng(int)'
   97 | int rng(int lim) {
      |     ^~~
a.cc:33:5: note: 'int rng(int)' previously defined here
   33 | int rng(int lim) {
      |     ^~~
a.cc:102:11: error: redefinition of 'const int mod'
  102 | const int mod = 1'000'000'007;
      |           ^~~
a.cc:38:11: note: 'const int mod' previously defined here
   38 | const int mod = 1'000'000'007;
      |           ^~~
a.cc:103:11: error: redefinition of 'const int N'
  103 | const int N = 3e5, M = N;
      |           ^
a.cc:39:11: note: 'const int N' previously defined here
   39 | const int N = 3e5, M = N;
      |           ^
a.cc:103:20: error: redefinition of 'const int M'
  103 | const int N = 3e5, M = N;
      |                    ^
a.cc:39:20: note: 'const int M' previously defined here
   39 | const int N = 3e5, M = N;
      |                    ^
a.cc:106:6: error: redefinition of 'void solve()'
  106 | void solve() {
      |      ^~~~~
a.cc:42:6: note: 'void solve()' previously defined here
   42 | void solve() {
      |      ^~~~~
a.cc:115:5: error: redefinition of 'int main()'
  115 | int main() {
      |     ^~~~
a.cc:51:5: note: 'int main()' previously defined here
   51 | int main() {
      |     ^~~~