Language: C++

#include <bits/stdc++.h>
#define LL __int64  
#define N 100005  
#define inf 0x3f3f3f3f  
#define pi acos(-1.0)  
#define eps 10e-6  
using namespace std;  
char s[N];  
int sa[N],t[N],t2[N],c[N],r[N];  
void build_sa(int n,int m)  
{  
    int i,k,*x = t,*y = t2;  
    for(i = 0; i < m; i++)  c[i] = 0;  
    for(i = 0; i < n; i++)  c[ x[i] = r[i] ]++;  
    for(i = 1; i < m; i++)  c[i] += c[i-1];  
    for(i = n-1; i >= 0; i--)   sa[ --c[ x[i] ] ] = i;  
  
    for(k = 1; k <= n; k<<=1)  
    {  
        int p = 0;  
        for(i = n-k; i < n; i++)    y[p++] = i;  
        for(i = 0; i < n; i++)  if(sa[i] >= k)  y[p++] = sa[i] - k;  
  
        for(i = 0; i < m; i++)  c[i] = 0;  
        for(i = 0; i < n; i++)  c[ x[ y[i] ] ]++;  
        for(i = 1; i < m; i++)  c[i] += c[i-1];  
        for(i = n-1; i >= 0; i--)   sa[ --c[ x[ y[i] ] ] ] = y[i];  
  
        swap(x,y);  
        p = 1; x[ sa[0] ] = 0;  
        for(i = 1; i < n; i++)  
            x[ sa[i] ] = y[ sa[i-1] ] == y[ sa[i] ] && y[ sa[i-1]+k ] == y[ sa[i]+k ] ? p-1 : p++;  
        if(p >= n) break;  
        m = p;  
    }  
}  
int rank[N],height[N];  
void getheight(int n)  
{  
    int i,j,k = 0;  
    for(i = 0; i <= n; i++)  rank[ sa[i] ] = i;  
    for(i = 0; i < n; i++)  {  
        if(k) k--;  
        j = sa[ rank[i]-1 ];  
        while(s[i+k] == s[j+k]) k++;  
        height[ rank[i] ] = k;  
    }  
}  
LL cnt[N];  
int main()  
{  
    scanf("%s",s);
    int n = strlen(s);  
    int i;  
    for(i = 0; i < n; i++)  
        r[i] = s[i] - 'a' + 1;  
    r[n] = 0;  
    build_sa(n+1,28);  
    getheight(n);  
    cnt[0] = -1;  
    for(i = 1; i <= n; i++)     cnt[i] = n - sa[i] - height[i];  
    for(i = 2; i <= n; i++)     cnt[i] += cnt[i-1];  
    int l = 0,r = 0;  
    LL k;  
    int cas;  
    scanf("%d",&cas);  
    while(cas--)  
    {  
        scanf("%I64d",&k);  
        k = (k^l^r)+1;  
        if(k > cnt[n]){  
            l = r = 0;  
            printf("%d %d\n",l,r);  
            continue;  
        }  
        int cur = lower_bound(cnt+1,cnt+n+1,k) - cnt;  
        if(cur > n) {  
            l = r = 0;  
        }  
        else {  
            LL ll = sa[cur];  
            LL rr = n - (cnt[cur] - k)-1;  
            int tot = rr-ll+1;  
            l = ll;  
            for(i = cur+1; i <= n; i++)  
            {  
                if(height[i] < tot)  break;  
                if(sa[i] < l)  
                    l = sa[i];  
            }  
            r = l+tot-1;  
            r++;l++;  
        }  
        printf("%d %d\n",l,r);  
    }  
    return 0;  
}

Compiler output:
a.cc: In function 'void getheight(int)':
a.cc:41:30: error: reference to 'rank' is ambiguous
   41 |     for(i = 0; i <= n; i++)  rank[ sa[i] ] = i;
      |                              ^~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
                 from /usr/include/c++/14/bits/stl_algobase.h:64,
                 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/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:37:5: note:                 'int rank [100005]'
   37 | int rank[N],height[N];
      |     ^~~~
a.cc:44:17: error: reference to 'rank' is ambiguous
   44 |         j = sa[ rank[i]-1 ];
      |                 ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:37:5: note:                 'int rank [100005]'
   37 | int rank[N],height[N];
      |     ^~~~
a.cc:46:17: error: reference to 'rank' is ambiguous
   46 |         height[ rank[i] ] = k;
      |                 ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:37:5: note:                 'int rank [100005]'
   37 | int rank[N],height[N];
      |     ^~~~
a.cc: At global scope:
a.cc:2:12: error: '__int64' does not name a type; did you mean '__int64_t'?
    2 | #define LL __int64
      |            ^~~~~~~
a.cc:49:1: note: in expansion of macro 'LL'
   49 | LL cnt[N];
      | ^~
a.cc: In function 'int main()':
a.cc:60:5: error: 'cnt' was not declared in this scope; did you mean 'int'?
   60 |     cnt[0] = -1;
      |     ^~~
      |     int
a.cc:2:12: error: '__int64' was not declared in this scope; did you mean '__ynf64'?
    2 | #define LL __int64
      |            ^~~~~~~
a.cc:64:5: note: in expansion of macro 'LL'
   64 |     LL k;
      |     ^~
a.cc:69:24: error: 'k' was not declared in this scope
   69 |         scanf("%I64d",&k);
      |                        ^
a.cc:81:16: error: expected ';' before 'll'
   81 |             LL ll = sa[cur];
      |                ^~
a.cc:82:16: error: expected ';' before 'rr'
   82 |             LL rr = n - (cnt[cur] - k)-1;
      |                ^~
a.cc:83:23: error: 'rr' was not declared in this scope; did you mean 'r'?
   83 |             int tot = rr-ll+1;
      |                       ^~
      |                       r
a.cc:83:26: error: 'll' was not declared in this scope; did you mean 'l'?
   83 |             int tot = rr-ll+1;
      |                          ^~
      |                          l