Language: C++

#include<bits/stdc++.h>
using namespace std;
char st[500010];
int go[500010][26],next[500010],w,len;
long long work(long long r,int ch)
{
	if (r<=len) return go[r][ch];
	long long n1=go[len/2][ch],n2=go[w][ch],l1=len/2,l2=w;
	while (l1+l2<=r)
	{
		long long tmp=l1;l1+=l2;l2=tmp;
		tmp=n1;n1+=n2;n2=tmp;
	}
	return n1+work(r-l1,ch);
}
int main()
{
	scanf("%s\n",st+1);len=strlen(st+1);
	for (int i=1;i<=len;i++)
	{
		for (int j=0;j<26;j++) go[i][j]=go[i-1][j];
		go[i][st[i]-'a']++;
	}
	next[0]=-1;
	for (int i=1;i<=len;i++)
	{
		int t=next[i-1];
		while ((t!=-1)&&(st[t+1]!=st[i])) t=next[t];
		next[i]=t+1;
	}
	w=next[len];
	while (w>=len/2) w=next[w];
	w=len/2-w;
	long long l,r;scanf("%lld%lld",&l,&r);
	for (int i=0;i<26;i++) printf("%lld ",work(r,i)-work(l-1,i));
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:9: error: reference to 'next' is ambiguous
   24 |         next[0]=-1;
      |         ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:4:20: note:                 'int next [500010]'
    4 | int go[500010][26],next[500010],w,len;
      |                    ^~~~
a.cc:27:23: error: reference to 'next' is ambiguous
   27 |                 int t=next[i-1];
      |                       ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:4:20: note:                 'int next [500010]'
    4 | int go[500010][26],next[500010],w,len;
      |                    ^~~~
a.cc:28:53: error: reference to 'next' is ambiguous
   28 |                 while ((t!=-1)&&(st[t+1]!=st[i])) t=next[t];
      |                                                     ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:4:20: note:                 'int next [500010]'
    4 | int go[500010][26],next[500010],w,len;
      |                    ^~~~
a.cc:29:17: error: reference to 'next' is ambiguous
   29 |                 next[i]=t+1;
      |                 ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:4:20: note:                 'int next [500010]'
    4 | int go[500010][26],next[500010],w,len;
      |                    ^~~~
a.cc:31:11: error: reference to 'next' is ambiguous
   31 |         w=next[len];
      |           ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:4:20: note:                 'int next [500010]'
    4 | int go[500010][26],next[500010],w,len;
      |                    ^~~~
a.cc:32:28: error: reference to 'next' is ambiguous
   32 |         while (w>=len/2) w=next[w];
      |                            ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:4:20: note:                 'int next [500010]'
    4 | int go[500010][26],next[500010],w,len;
      |                    ^~~~