Language: C++

#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define repd(i,n) for(int (i)=n-1;(i)>=0;i--)
#define REPD(i,n) for(int (i)=n;(i)>0;i--) 
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())

const int Maxn=200005;
const int Maxm=30;
const int Hash=31;
int n,match;
string s;
ll l,r;
int hash[Maxn],power[Maxn];
int cnt[Maxn][Maxm];
ll ans[Maxm];
vector<ll>L,R;

bool same(int pos){
	int k1=hash[pos-1],k2=hash[n-1]-hash[n-1-pos]*power[pos];
	return k1==k2;
}

vector<ll> add_ans(vector<ll>a,vector<ll>b){
	rep(i,26)a[i]+=b[i];
	return a;
}

pair<ll,vector<ll> > solve(ll l_len,vector<ll>L,ll r_len,vector<ll>R,ll rest){
	vector<ll>res(26);
	if(l_len+r_len<=rest){
		vector<ll>sum=add_ans(L,R);
		pair<ll,vector<ll> >ret=solve(l_len+r_len,sum,l_len,L,rest);
		rest=ret.fi;
		res=add_ans(res,ret.se);
	}
	if(l_len<=rest){
		res=add_ans(res,L);
		rest-=l_len;
	}
	return mk(rest,res);
}

int main(){
	ios::sync_with_stdio(false);
	cin>>s>>l>>r;
	l--;r--;
	s=s.substr(0,s.size()/2);
	n=sz(s);

	hash[0]=s[0]-'a';power[0]=1;
	REP(i,n-1)hash[i]=hash[i-1]*Hash+s[i]-'a',power[i]=power[i-1]*Hash;
	REP(i,n-1)if(same(i))match=max(match,i);

	rep(i,n){
		rep(j,26){
			if(j==s[i]-'a')cnt[i][j]=!i?1:cnt[i-1][j]+1;
			else cnt[i][j]=!i?0:cnt[i-1][j];
		}
	}

	if(match==0){
		rep(i,26){
			ans[i]+=(ll)cnt[n-1][i]*(ll)(r/(ll)n)+(ll)cnt[r%(ll)n][i];
			if((l-1)>=0)ans[i]-=(ll)cnt[n-1][i]*(ll)((l-1)/(ll)n)+(ll)cnt[(l-1)%(ll)n][i];
		}
		rep(i,26)cout<<ans[i]<<" ";
		return 0;
	}
	
	else{
		L.resize(26);R.resize(26);
		rep(i,26)R[i]=cnt[match-1][i];
		rep(i,26)L[i]=cnt[n-1][i]-cnt[match-1][i];
		pair<ll,vector<ll> >ans_R=solve(n-match,L,match,R,r);
		pair<ll,vector<ll> >ans_L=solve(n-match,L,match,R,l-1);
		rep(i,26){
			ans[i]+=ans_R.se[i]+cnt[ans_R.fi][i];
			ans[i]-=ans_L.se[i]+cnt[ans_L.fi][i];
		}
		rep(i,26)cout<<ans[i]<<" ";
		return 0;
	}
}
/*
vgxgpuamkvgxgvgxgpuamkvgxg
1 1000000000000000000
*/ 

Compiler output:
a.cc: In function 'bool same(int)':
a.cc:69:16: error: reference to 'hash' is ambiguous
   69 |         int k1=hash[pos-1],k2=hash[n-1]-hash[n-1-pos]*power[pos];
      |                ^~~~
In file included from /usr/include/c++/14/string_view:50,
                 from /usr/include/c++/14/bits/basic_string.h:47,
                 from /usr/include/c++/14/string:54,
                 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:2:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:63:5: note:                 'int hash [200005]'
   63 | int hash[Maxn],power[Maxn];
      |     ^~~~
a.cc:70:20: error: 'k2' was not declared in this scope; did you mean 'k1'?
   70 |         return k1==k2;
      |                    ^~
      |                    k1
a.cc: In function 'int main()':
a.cc:100:9: error: reference to 'hash' is ambiguous
  100 |         hash[0]=s[0]-'a';power[0]=1;
      |         ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:63:5: note:                 'int hash [200005]'
   63 | int hash[Maxn],power[Maxn];
      |     ^~~~
a.cc:101:19: error: reference to 'hash' is ambiguous
  101 |         REP(i,n-1)hash[i]=hash[i-1]*Hash+s[i]-'a',power[i]=power[i-1]*Hash;
      |                   ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:63:5: note:                 'int hash [200005]'
   63 | int hash[Maxn],power[Maxn];
      |     ^~~~
a.cc:101:27: error: reference to 'hash' is ambiguous
  101 |         REP(i,n-1)hash[i]=hash[i-1]*Hash+s[i]-'a',power[i]=power[i-1]*Hash;
      |                           ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:63:5: note:                 'int hash [200005]'
   63 | int hash[Maxn],power[Maxn];
      |     ^~~~