Language: C++

#include <bits/stdc++.h>
using namespace std;
#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 fo(i,k,n)   for(int i = k;i<n; i++)
#define ro(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
#define W(x)        cout<<x<<endl
#define WW(x,y)     cout<<x<<' '<<y<<endl;
#define in(x)       cin>>x
#define v(x)        vector<x>
#define int         long long
#define ar(x,y)     array<x,y>
const ll mod1 = 99844353;
const ll mod2 = 1e9+7;
/* 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 dsu{
  unordered_map<int,int> pr,sz;
  dsu(){
    (this->pr).clear();
    (this->sz).clear();
  }
  void make(int x){
    pr[x] = x;
    sz[x] = 1;
  }
  int getpar(int x){
    if(pr[x] == x)return x;
    return pr[x] = getpar(pr[x]);
  }
  void merge(int x,int y){
    x = getpar(x);
    y = getpar(y);
    if(sz[x]<sz[y])swap(x,y);
    pr[y] = x;
    sz[x]+=sz[y];
    sz[y] = 0;
  }
};

int x;

class data{
public:
  int count;

		data(int val){
		    this->count = (val == x ? 1 : 0);
		}

		data(){}
};

data combine(data l, data r) {
    data res;
    res.count = l.count + r.count;
    return res;
}

class Seg_Tree{
public:
  int n;
	vector<data> seg;

		Seg_Tree(int sz){
			this->n = sz;
			this->seg.resize(4*n);
		}

		void build(int a[], int v, int tl, int tr) {
		    if (tl == tr) {
		        seg[v] = data(a[tl]);
		    } else {
		        int tm = (tl + tr) / 2;
		        build(a, v*2, tl, tm);
		        build(a, v*2+1, tm+1, tr);
		        seg[v] = combine(seg[v*2], seg[v*2+1]);
		    }
		}

		void update(int v, int tl, int tr, int pos, int new_val) {
		    if (tl == tr) {
		        seg[v] = 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);
		        seg[v] = combine(seg[v*2], seg[v*2+1]);
		    }
		}

		data query(int v, int tl, int tr, int l, int r) {
		    if (l > r)
		        return data(0);
		    if (l == tl && r == tr)
		        return seg[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));
		}
		int find_kth(int v, int tl, int tr, int k) {
		    if (k > seg[v].count)
		        return -1;
		    if (tl == tr)
		        return tl;
		    int tm = (tl + tr) / 2;
		    if (seg[v*2].count >= k)
		        return find_kth(v*2, tl, tm, k);
		    else
		        return find_kth(v*2+1, tm+1, tr, k - seg[v*2].count);
		}
};

void solve(){
  int l,r,d;
  cin>>l>>r>>d;
  int start = (l%d == 0 ? l/d : l/d+1);
  int end = r/d;
  cout<<end-start+1<<"\n";
}

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


Compiler output:
a.cc:84:1: error: reference to 'data' is ambiguous
   84 | data combine(data l, data r) {
      | ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 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:73:7: note:                 'class data'
   73 | class data{
      |       ^~~~
a.cc:93:20: error: template argument 1 is invalid
   93 |         vector<data> seg;
      |                    ^
a.cc:93:20: error: template argument 2 is invalid
a.cc:124:17: error: reference to 'data' is ambiguous
  124 |                 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:73:7: note:                 'class data'
   73 | class data{
      |       ^~~~
a.cc: In constructor 'Seg_Tree::Seg_Tree(long long int)':
a.cc:97:35: error: request for member 'resize' in '((Seg_Tree*)this)->Seg_Tree::seg', which is of non-class type 'int'
   97 |                         this->seg.resize(4*n);
      |                                   ^~~~~~
a.cc: In member function 'void Seg_Tree::build(long long int*, long long int, long long int, long long int)':
a.cc:102:28: error: invalid types 'int[long long int]' for array subscript
  102 |                         seg[v] = data(a[tl]);
      |                            ^
a.cc:102:34: error: reference to 'data' is ambiguous
  102 |                         seg[v] = data(a[tl]);
      |                                  ^~~~
/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:73:7: note:                 'class data'
   73 | class data{
      |       ^~~~
a.cc:107:28: error: invalid types 'int[long long int]' for array subscript
  107 |                         seg[v] = combine(seg[v*2], seg[v*2+1]);
      |                            ^
a.cc:107:45: error: invalid types 'int[long long int]' for array subscript
  107 |                         seg[v] = combine(seg[v*2], seg[v*2+1]);
      |                                             ^
a.cc:107:55: error: invalid types 'int[long long int]' for array subscript
  107 |                         seg[v] = combine(seg[v*2], seg[v*2+1]);
      |                                                       ^
a.cc:107:34: error: 'combine' was not declared in this scope
  107 |                         seg[v] = combine(seg[v*2], seg[v*2+1]);
      |                                  ^~~~~~~
a.cc: In member function 'void Seg_Tree::update(long long int, long long int, long long int, long long int, long long int)':
a.cc:113:28: error: invalid types 'int[long long int]' for array subscript
  113 |                         seg[v] = data(new_val);
      |                            ^
a.cc:113:34: error: reference to 'data' is ambiguous
  113 |                         seg[v] = data(new_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:73:7: note:                 'class data'
   73 | class data{
      |       ^~~~
a.cc:120:28: error: invalid types 'int[long long int]' for array subscript
  120 |                         seg[v] = combine(seg[v*2], seg[v*2+1]);
      |                            ^
a.cc:120:45: error: invalid types 'int[long long int]' for array subscript
  120 |                         seg[v] = combine(seg[v*2], seg[v*2+1]);
      |                                             ^
a.cc:120:55: error: invalid types 'int[long long int]' for array subscript
  120 |                         seg[v] = combine(seg[v*2], seg[v*2+1]);
      |                                                       ^
a.cc:120:34: error: 'combine' was not declared in this scope
  120 |                         seg[v] = combine(seg[v*2], seg[v*2+1]);
      |                                  ^~~~~~~
a.cc: In member function 'long long int Seg_Tree::find_kth(long long int, long long int, long long int, long long int)':
a.cc:134:32: error: invalid types 'int[long long int]' for array subscript
  134 |                     if (k > seg[v].count)
      |                                ^
a.cc:139:28: error: invalid types 'int[long long int]' for array subscript
  139 |                     if (seg[v*2].count >= k)
      |                            ^
a.cc:142:65: error: invalid types 'int[long long int]' for array subscript
  142 |                         return find_kth(v*2+1, tm+1, tr, k - seg[v*2].count);
      |                                                                 ^