Language: C++

#include <iostream>

using namespace std;
int a[200005];
int b[200005];
int aa[400005];
int bb[200005];
int next[200005]={0};
int ans[200005];
int n;
void next_()
{
    next[0]=-1;
    int k=-1;
    int j=0;
    while(j<n)
    {
        if(k==-1||bb[k]==bb[j])
        {
            k++;
            j++;
            if(bb[k]==bb[j])
                next[j]=next[k];
            else
                next[j]=k;
        }
        else
            k=next[k];
    }
}
int main()
{
    cin.tie(NULL);
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {
        cin>>b[i];
    }
    for(int i=0;i<n;i++)
    {
        aa[i]=a[i]^a[(i+1)%n];
        aa[i+n]=aa[i];
        bb[i]=b[i]^b[(i+1)%n];
    }
    next_();
    for(int i=0;i<n;i++)
        ans[i]=-1;
    /*for(int i=0;i<n;i++)
    {
        cout<<bb[i]<<" ";
    }
    cout<<endl;
    for(int k=0;k<=n;k++)
    {
        cout<<next[k]<<" ";
    }
    cout<<endl;*/
    int i=0;
    int j=-1;
   while(i<2*n-1)
   {
       while(i<2*n-1&&j<n)
       {
           if(j==-1||bb[j]==aa[i])
           {
                i++;
                j++;
           }
           else
            j=next[j];
       }
       if(j>=n)
       {
           ans[i-n]=b[0]^a[i-n];
           j=next[j];
       }
   }
    for(int k=0;k<n;k++)
    {
        if(ans[k]!=-1)
            cout<<k<<" "<<ans[k]<<endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'void next_()':
a.cc:13:5: error: reference to 'next' is ambiguous
   13 |     next[0]=-1;
      |     ^~~~
In file included from /usr/include/c++/14/string:47,
                 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/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:8:5: note:                 'int next [200005]'
    8 | int next[200005]={0};
      |     ^~~~
a.cc:23:17: error: reference to 'next' is ambiguous
   23 |                 next[j]=next[k];
      |                 ^~~~
/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:8:5: note:                 'int next [200005]'
    8 | int next[200005]={0};
      |     ^~~~
a.cc:23:25: error: reference to 'next' is ambiguous
   23 |                 next[j]=next[k];
      |                         ^~~~
/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:8:5: note:                 'int next [200005]'
    8 | int next[200005]={0};
      |     ^~~~
a.cc:25:17: error: reference to 'next' is ambiguous
   25 |                 next[j]=k;
      |                 ^~~~
/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:8:5: note:                 'int next [200005]'
    8 | int next[200005]={0};
      |     ^~~~
a.cc:28:15: error: reference to 'next' is ambiguous
   28 |             k=next[k];
      |               ^~~~
/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:8:5: note:                 'int next [200005]'
    8 | int next[200005]={0};
      |     ^~~~
a.cc: In function 'int main()':
a.cc:74:15: error: reference to 'next' is ambiguous
   74 |             j=next[j];
      |               ^~~~
/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:8:5: note:                 'int next [200005]'
    8 | int next[200005]={0};
      |     ^~~~
a.cc:79:14: error: reference to 'next' is ambiguous
   79 |            j=next[j];
      |              ^~~~
/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:8:5: note:                 'int next [200005]'
    8 | int next[200005]={0};
      |     ^~~~