Language: C++

#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m;
ll k;
ll x[100005];
int a[100005];
int next[100005];
int tmp[100005];
int res[100005];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lld",&x[i]);
	}
	for(int i=0;i<n-1;i++){
		next[i]=i;
		res[i]=i;
	}
	scanf("%d%lld",&m,&k);
	for(int i=0;i<m;i++){
		scanf("%d",&a[i]);
		a[i]--;
	}
	for(ll i=0;i<m;i++){
		swap(next[a[i]-1],next[a[i]]);
	}
	while(k>0){
		if(k&1){
			for(int i=0;i<n-1;i++){
				res[i]=next[res[i]];
			}
		}
		for(int i=0;i<n-1;i++){
			tmp[i]=next[next[i]];
		}
		for(int i=0;i<n-1;i++){
			next[i]=tmp[i];
		}
		k>>=1;
	}
	ll now=x[0];
	for(int i=0;i<n;i++){
		printf("%lld\n",now);
		now+=x[res[i]+1]-x[res[i]];
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:17: error: reference to 'next' is ambiguous
   34 |                 next[i]=i;
      |                 ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/vector:62,
                 from a.cc:3:
/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:24:5: note:                 'int next [100005]'
   24 | int next[100005];
      |     ^~~~
a.cc:43:22: error: reference to 'next' is ambiguous
   43 |                 swap(next[a[i]-1],next[a[i]]);
      |                      ^~~~
/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:24:5: note:                 'int next [100005]'
   24 | int next[100005];
      |     ^~~~
a.cc:43:35: error: reference to 'next' is ambiguous
   43 |                 swap(next[a[i]-1],next[a[i]]);
      |                                   ^~~~
/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:24:5: note:                 'int next [100005]'
   24 | int next[100005];
      |     ^~~~
a.cc:48:40: error: reference to 'next' is ambiguous
   48 |                                 res[i]=next[res[i]];
      |                                        ^~~~
/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:24:5: note:                 'int next [100005]'
   24 | int next[100005];
      |     ^~~~
a.cc:52:32: error: reference to 'next' is ambiguous
   52 |                         tmp[i]=next[next[i]];
      |                                ^~~~
/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:24:5: note:                 'int next [100005]'
   24 | int next[100005];
      |     ^~~~
a.cc:52:37: error: reference to 'next' is ambiguous
   52 |                         tmp[i]=next[next[i]];
      |                                     ^~~~
/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:24:5: note:                 'int next [100005]'
   24 | int next[100005];
      |     ^~~~
a.cc:55:25: error: reference to 'next' is ambiguous
   55 |                         next[i]=tmp[i];
      |                         ^~~~
/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:24:5: note:                 'int next [100005]'
   24 | int next[100005];
      |     ^~~~