Language: C++

#include <iostream>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define li long
#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pii pair<int,int>
#define pli pair<li,li>
#define pll pair<ll,ll>
#define pb push_back
#define fori(i,k,n) for(int i = k;i<n; i++)
#define rfori(i,k,n) for(int i = k; i>=n; i--)
#define tc int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define inf INT_MAX
#define ninf INT_MIN
template <class T>
using oset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
} 
template<class T>
T power(T a,T b){
    T res = (T)1;
    while(b>0){
        if(b&1)res = res*a;
        b>>=1;
        a*=a;
    }
    return res;
}
struct trie{
    map<char,trie*> mp;

};
//int n,b[50000],a[50000][32];
struct data {
    ll sum, pref, suff, ans;
};

data combine(data l, data r) {
    data res;
    res.sum = l.sum + r.sum;
    res.pref = max(l.pref, l.sum + r.pref);
    res.suff = max(r.suff, r.sum + l.suff);
    res.ans = max(max(l.ans, r.ans), l.suff + r.pref);
    return res;
}

//vector<ll> a(mxn);
vector<data> t(4*mxn);

data make_data(ll val) {
    data res;
    res.sum = val;
    res.pref = res.suff = res.ans = max(0*1LL,val);
    return res;
}

void build(int v, int tl, int tr) {
    if (tl == tr) {
        t[v] = make_data(a[tl]);
    } else {
        int tm = (tl + tr) / 2;
        build(v*2, tl, tm);
        build(v*2+1, tm+1, tr);
        t[v] = combine(t[v*2], t[v*2+1]);
    }
}
data query(int v, int tl, int tr, int l, int r) {
    if (l > r) 
        return make_data(0);
    if (l == tl && r == tr) 
        return t[v];
    int tm = (tl + tr) / 2;
    return combine(query(v*2, tl, tm, l, min(r, tm)), 
                   query(v*2+1, tm+1, tr, max(l, tm+1), r));
}
void update(int v, int tl, int tr, int pos, ll new_val) {
    if (tl == tr) {
        t[v] = make_data(new_val);
    } else {
        int tm = (tl + tr) / 2;
        if (pos <= tm)
            update(v*2, tl, tm, pos, new_val);
        else
            update(v*2+1, tm+1, tr, pos, new_val);
        t[v] = combine(t[v*2], t[v*2+1]);
    }
}


int main(){
    
    fastio();
    ll x;
    cin>>x;
    cout<<(x/500)+(x%500)/5<<"\n";
}   

Compiler output:
a.cc:50:1: error: reference to 'data' is ambiguous
   50 | data combine(data l, data r) {
      | ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:46:8: note:                 'struct data'
   46 | struct data {
      |        ^~~~
a.cc:60:12: error: template argument 1 is invalid
   60 | vector<data> t(4*mxn);
      |            ^
a.cc:60:12: error: template argument 2 is invalid
a.cc:60:18: error: 'mxn' was not declared in this scope
   60 | vector<data> t(4*mxn);
      |                  ^~~
a.cc:62:1: error: reference to 'data' is ambiguous
   62 | data make_data(ll val) {
      | ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:46:8: note:                 'struct data'
   46 | struct data {
      |        ^~~~
a.cc: In function 'void build(int, int, int)':
a.cc:71:10: error: invalid types 'int[int]' for array subscript
   71 |         t[v] = make_data(a[tl]);
      |          ^
a.cc:71:26: error: 'a' was not declared in this scope
   71 |         t[v] = make_data(a[tl]);
      |                          ^
a.cc:71:16: error: 'make_data' was not declared in this scope
   71 |         t[v] = make_data(a[tl]);
      |                ^~~~~~~~~
a.cc:76:10: error: invalid types 'int[int]' for array subscript
   76 |         t[v] = combine(t[v*2], t[v*2+1]);
      |          ^
a.cc:76:25: error: invalid types 'int[int]' for array subscript
   76 |         t[v] = combine(t[v*2], t[v*2+1]);
      |                         ^
a.cc:76:33: error: invalid types 'int[int]' for array subscript
   76 |         t[v] = combine(t[v*2], t[v*2+1]);
      |                                 ^
a.cc:76:16: error: 'combine' was not declared in this scope
   76 |         t[v] = combine(t[v*2], t[v*2+1]);
      |                ^~~~~~~
a.cc: At global scope:
a.cc:79:1: error: reference to 'data' is ambiguous
   79 | data query(int v, int tl, int tr, int l, int r) {
      | ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:46:8: note:                 'struct data'
   46 | struct data {
      |        ^~~~
a.cc: In function 'void update(int, int, int, int, long long int)':
a.cc:90:10: error: invalid types 'int[int]' for array subscript
   90 |         t[v] = make_data(new_val);
      |          ^
a.cc:90:16: error: 'make_data' was not declared in this scope
   90 |         t[v] = make_data(new_val);
      |                ^~~~~~~~~
a.cc:97:10: error: invalid types 'int[int]' for array subscript
   97 |         t[v] = combine(t[v*2], t[v*2+1]);
      |          ^
a.cc:97:25: error: invalid types 'int[int]' for array subscript
   97 |         t[v] = combine(t[v*2], t[v*2+1]);
      |                         ^
a.cc:97:33: error: invalid types 'int[int]' for array subscript
   97 |         t[v] = combine(t[v*2], t[v*2+1]);
      |                                 ^
a.cc:97:16: error: 'combine' was not declared in this scope
   97 |         t[v] = combine(t[v*2], t[v*2+1]);
      |                ^~~~~~~