Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double db;
#define go(u) for(int i = head[u], v = e[i].to; i; i=e[i].lst, v=e[i].to)
#define rep(i, a, b) for(int i = a; i <= b; ++i)
#define pb push_back
#define re(x) memset(x, 0, sizeof x)
inline int gi() {
    int x = 0,f = 1;
    char ch = getchar();
    while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getchar();}
    while(isdigit(ch)) { x = (x << 3) + (x << 1) + ch - 48; ch = getchar();}
    return x * f;
}
template <typename T> inline bool Max(T &a, T b){return a < b ? a = b, 1 : 0;}
template <typename T> inline bool Min(T &a, T b){return a > b ? a = b, 1 : 0;}
const int N = 1e5 + 7;
int n, m;
int replace[N], stk[N], res[N], vis[N];
LL x[N], ans[N], k;
int main() {
#ifdef fwat
	freopen("data.in", "r", stdin);
#endif
	n = gi();
	rep(i, 1, n) x[i] = gi(), replace[i] = i;
	scanf("%d%lld", &m, &k);
	rep(i, 1, m) {
		int x = gi();
		swap(replace[x], replace[x + 1]);
	}
	rep(i, 1, n) if(!vis[i]) {
		int tp = 0;
		for(int j = i; !vis[j]; j = replace[j]) stk[tp++] = j, vis[j] = 1;
		for(int j = 0; j < tp; ++j) 
		res[stk[j]] = stk[(j + k) % tp];
	}
	rep(i, 1, n) ans[i] = ans[i - 1] + x[res[i]] - x[res[i] - 1];
	rep(i, 1, n) printf("%lld\n", ans[i]);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:35: error: reference to 'replace' is ambiguous
   27 |         rep(i, 1, n) x[i] = gi(), replace[i] = i;
      |                                   ^~~~~~~
In file included from /usr/include/c++/14/algorithm:86,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:174:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::replace(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&, const _Tp&)'
  174 | replace(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __old_value,
      | ^~~~~~~
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:4280:5: note:                 'template<class _FIter, class _Tp> void std::replace(_FIter, _FIter, const _Tp&, const _Tp&)'
 4280 |     replace(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~
a.cc:20:5: note:                 'int replace [100007]'
   20 | int replace[N], stk[N], res[N], vis[N];
      |     ^~~~~~~
a.cc:31:22: error: reference to 'replace' is ambiguous
   31 |                 swap(replace[x], replace[x + 1]);
      |                      ^~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:174:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::replace(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&, const _Tp&)'
  174 | replace(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __old_value,
      | ^~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4280:5: note:                 'template<class _FIter, class _Tp> void std::replace(_FIter, _FIter, const _Tp&, const _Tp&)'
 4280 |     replace(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~
a.cc:20:5: note:                 'int replace [100007]'
   20 | int replace[N], stk[N], res[N], vis[N];
      |     ^~~~~~~
a.cc:31:34: error: reference to 'replace' is ambiguous
   31 |                 swap(replace[x], replace[x + 1]);
      |                                  ^~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:174:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::replace(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&, const _Tp&)'
  174 | replace(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __old_value,
      | ^~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4280:5: note:                 'template<class _FIter, class _Tp> void std::replace(_FIter, _FIter, const _Tp&, const _Tp&)'
 4280 |     replace(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~
a.cc:20:5: note:                 'int replace [100007]'
   20 | int replace[N], stk[N], res[N], vis[N];
      |     ^~~~~~~
a.cc:35:45: error: reference to 'replace' is ambiguous
   35 |                 for(int j = i; !vis[j]; j = replace[j]) stk[tp++] = j, vis[j] = 1;
      |                                             ^~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:174:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::replace(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&, const _Tp&)'
  174 | replace(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __old_value,
      | ^~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4280:5: note:                 'template<class _FIter, class _Tp> void std::replace(_FIter, _FIter, const _Tp&, const _Tp&)'
 4280 |     replace(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~
a.cc:20:5: note:                 'int replace [100007]'
   20 | int replace[N], stk[N], res[N], vis[N];
      |     ^~~~~~~