stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;



typedef long long ll;



bool vis[100050];

ll w[100050], nxt[100050], que[100050], output[100050];



int main(){

	int n, m;

	scanf("%d", &n);

	for(int i = 1; i <= n; i++) scanf("%lld", &w[i]), nxt[i] = i;

	for(int i = n; i >= 1; i--) w[i] -= w[i-1];

	ll k;

	ll a;

	scanf("%d %lld", &m, &k);

	for(int i = 1; i <= m; i++) scanf("%lld", &a), swap(nxt[a], nxt[a+1]);

	for(int i = 1; i <= n; i++){

		if(!vis[i]) {

			int now = i, cnt = 0;

			while(!vis[now]){

				vis[now] = 1;

				que[++cnt] = now;

				now = nxt[now];

			}

			for(int j = 1; j <= cnt; j++){

				ll t = (0ll+j+k-2)%cnt+1;

				output[que[j]] = w[nxt[que[t]]];

			}

		}

	}

	ll p = 0;

	for(int i = 1; i <= n; i++) p += output[i], printf("%lld\n", p);

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

#define int long long

const int N=200003;

int x[N],ans[N],g[N],n,m,k,used[N],siz;

signed main(){

	scanf("%lld",&n);

	for(int i=1;i<=n;i++)scanf("%lld",x+i),g[i]=i;

	for(int i=n;i;i--)x[i]-=x[i-1];

	scanf("%lld%lld",&m,&k);

	for(int i,j=1;j<=m;j++)scanf("%lld",&i),std::swap(g[i],g[i+1]);

	for(int i=1,j,v;i<=n;i++)if(!used[i]){

	  siz=1;

	  for(j=g[i];j!=i;j=g[j])

		siz++;

	  j=i;

	  for(int id=1;id<=k%siz;id++)j=g[j];

	  ans[i]=x[j],used[j]=1;

	  for(j=g[j],v=g[i];!used[j];j=g[j],v=g[v])

		ans[v]=x[j],used[j]=1;

	}

	for(int i=1;i<=n;i++)printf("%lld\n",ans[i]+=ans[i-1]);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

typedef long long LL;

const int N=1e5+7;

LL jmp,a,k,n,m,x[N],y[N],p[N],g[N],siz[N],tot,cnt,sum;

bitset <N> vis;

int main()

{

	scanf("%lld",&n);

	for(int i=1;i<=n;i++)scanf("%lld",&x[i]),p[i]=i;

	for(int i=1;i<=n;i++)y[i]=x[i]-x[i-1];

	scanf("%lld%lld",&m,&k);

	for(int i=1;i<=m;i++)

	{

		scanf("%lld",&a);

		swap(p[a],p[a+1]);

	}

	for(int i=1;i<=n;i++)if(!vis[i])

	{

		++cnt;int res=i;

		while(!vis[res])

			g[res]=cnt,vis[res]=1,res=p[res],++siz[cnt];

	}

	for(int i=1;i<=n;i++)

	{

		jmp=k%siz[g[i]];

		int res=i;

		if(jmp)while(jmp--)res=p[res];

		sum+=y[res];

		printf("%lld.0\n",sum);

	}

} 

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

#define int long long

const int N=200003;

int x[N],ans[N],g[N],n,m,k,used[N],siz;

signed main(){

	scanf("%lld",&n);

	for(int i=1;i<=n;i++)scanf("%lld",x+i),g[i]=i;

	for(int i=n;i;i--)x[i]-=x[i-1];

	scanf("%lld%lld",&m,&k);

	for(int i,j=1;j<=m;j++)scanf("%lld",&i),std::swap(g[i],g[i+1]);

	for(int i=1,j,v;i<=n;i++)if(!used[i]){

	  siz=1;

	  for(j=g[i];j!=i;j=g[j])

		siz++;

	  j=i;

	  for(int id=1;id<=k%siz;id++)j=g[j];

	  ans[i]=x[j],used[j]=1;

	  for(j=g[j],v=g[i];!used[j];j=g[j],v=g[v])

		ans[v]=x[j],used[j]=1;

	}

	for(int i=1;i<=n;i++)printf("%lld\n",ans[i]+=ans[i-1]);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

#include<cstdlib>

#include<algorithm>

#include<cmath>

#include<queue>

using namespace std;

const int maxn = 1e6+7;

typedef long long ll;





ll n,m,pos[maxn],k,ans[maxn];

ll a[maxn],b[maxn],st[maxn];

ll move[maxn],vis[maxn];







int main()

{

	scanf("%lld",&n);

	for(int i=1;i<=n;i++)

		scanf("%lld",&pos[i]);

	for(int i=1;i<=n;i++)

		b[i]=pos[i]-pos[i-1],a[i]=i;

	scanf("%lld%lld",&m,&k);

	for(int i=1;i<=m;i++)

	{

		ll x;

		scanf("%lld",&x);

		swap(a[x],a[x+1]);

	}

	for(int t=1;t<=n;t++)

	{

		if(vis[t])continue;

		int round = 0;

		for(int i=t;!vis[i];i=a[i])vis[i]=1,st[++round]=i;

		for(int i=1;i<=round;i++) ans[st[i]] = b[ st[(i+k-1)%round +1]];

	}

	for(int i=1;i<=n;i++)

	{

		ans[i]+=ans[i-1];

		printf("%.1lf\n",(double)ans[i]);

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

#define int long long

const int N=200003;

int x[N],ans[N],g[N],n,m,k,used[N],siz;

signed main(){

	scanf("%lld",&n);

	for(int i=1;i<=n;i++)scanf("%lld",x+i),g[i]=i;

	for(int i=n;i;i--)x[i]-=x[i-1];

	scanf("%lld%lld",&m,&k);

	for(int i,j=1;j<=m;j++)scanf("%lld",&i),std::swap(g[i],g[i+1]);

	for(int i=1,j,v;i<=n;i++)if(!used[i]){

	  siz=1;

	  for(j=g[i];j!=i;j=g[j])

		siz++;

	  j=i;

	  for(int id=1;id<=k%siz;id++)j=g[j];

	  ans[i]=x[j],used[j]=1;

	  for(j=g[j],v=g[i];!used[j];j=g[j],v=g[v])

		ans[v]=x[j],used[j]=1;

	}

	for(int i=1;i<=n;i++)printf("%lld\n",ans[i]+=ans[i-1]);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#define fo(i,l,r) for(int i=l;i<=r;i++)

#define of(i,l,r) for(int i=l;i>=r;i--)

#define fe(i,u) for(int i=head[u];i;i=e[i].next)

#define el putchar('\n')

#define ta putchar('	')

using namespace std;

typedef long long ll;

typedef pair<int,int> pii;

inline void open(const char *s)

{

	#ifndef ONLINE_JUDGE

	char str[20];

	sprintf(str,"%s.in",s);

	freopen(str,"r",stdin);

//	sprintf(str,"%s.out",s);

//	freopen(str,"w",stdout);

	#endif

}

inline ll rd()

{

	static ll x,f;

	x=0;f=1;

	char ch=getchar();

	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;

	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';

	return f>0?x:-x;

}

const int N=100010;

int n,a[N],p[N],f[N];

ll b[N];

bool vis[N];



int main()

{

	n=rd();

	fo(i,1,n){

		a[i]=rd();

		b[i]=a[i]-a[i-1];

		f[i]=p[i]=i;

	}

	int m=rd();ll K=rd();

	fo(i,1,m){

		int x=rd();

		swap(p[x],p[x+1]);

	}

	fo(x,2,n)if(!vis[x]){

		int u=x;

		static vector<int>vec;

		vec.clear();

		for(;!vis[u];u=p[u])vec.push_back(u),vis[u]=1;

		int siz=vec.size();

		fo(i,0,siz-1)f[vec[i]]=vec[(i+K%siz)%siz];

	}

	ll hh=0;

	fo(i,1,n)printf("%lld.0\n",hh+=b[f[i]]);

	return 0;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

#define int long long

const int N=200003;

int x[N],ans[N],g[N],n,m,k,used[N],siz;

signed main(){

	scanf("%lld",&n);

	for(int i=1;i<=n;i++)scanf("%lld",x+i),g[i]=i;

	for(int i=n;i;i--)x[i]-=x[i-1];

	scanf("%lld%lld",&m,&k);

	for(int i,j=1;j<=m;j++)scanf("%lld",&i),std::swap(g[i],g[i+1]);

	for(int i=1,j,v;i<=n;i++)if(!used[i]){

	  siz=1;

	  for(j=g[i];j!=i;j=g[j])

		siz++;

	  j=i;

	  for(int id=1;id<=k%siz;id++)j=g[j];

	  ans[i]=x[j],used[j]=1;

	  for(j=g[j],v=g[i];!used[j];j=g[j],v=g[v])

		ans[v]=x[j],used[j]=1;

	}

	for(int i=1;i<=n;i++)printf("%lld\n",ans[i]+=ans[i-1]);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cstdio>

#include <cmath>

#define rep(i,a,b) for(int i=a;i<=b;i++)

#define per(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

const int N=2e5+5;

long long a[N],n,m,k,vis[N],b[N],cnt,lop[N],ans[N],res[N];

int main(){

	scanf("%lld",&n);

	rep(i,1,n) scanf("%lld",&a[i]);

	per(i,n,1) a[i]=a[i]-a[i-1],b[i]=i;

	scanf("%lld%lld",&m,&k);

	rep(i,1,m){

		int R;

		scanf("%d",&R);

		swap(b[R],b[R+1]);

	}

	rep(i,1,n){

		if(vis[i]) continue;

		lop[cnt=1]=i;

		for(int pos=b[i];pos!=i;pos=b[pos]){

			vis[pos]=1;

			lop[++cnt]=pos;

		}

		rep(j,1,cnt) ans[lop[j]]=lop[(j+k-1)%cnt+1];

	}

	rep(i,1,n) res[i]=a[ans[i]];

	rep(i,1,n) printf("%lld.0\n",res[i]+=res[i-1]);

	return 0;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

#define int long long

const int N=200003;

int x[N],ans[N],g[N],n,m,k,used[N],siz;

signed main(){

	scanf("%lld",&n);

	for(int i=1;i<=n;i++)scanf("%lld",x+i),g[i]=i;

	for(int i=n;i;i--)x[i]-=x[i-1];

	scanf("%lld%lld",&m,&k);

	for(int i,j=1;j<=m;j++)scanf("%lld",&i),std::swap(g[i],g[i+1]);

	for(int i=1,j,v;i<=n;i++)if(!used[i]){

	  siz=1;

	  for(j=g[i];j!=i;j=g[j])

		siz++;

	  j=i;

	  for(int id=1;id<=k%siz;id++)j=g[j];

	  ans[i]=x[j],used[j]=1;

	  for(j=g[j],v=g[i];!used[j];j=g[j],v=g[v])

		ans[v]=x[j],used[j]=1;

	}

	for(int i=1;i<=n;i++)printf("%lld\n",ans[i]+=ans[i-1]);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

 

using namespace std;

using namespace __gnu_pbds;

 

#define fi first

#define se second

#define mp make_pair

#define pb push_back

#define fbo find_by_order

#define ook order_of_key

 

typedef long long ll;

typedef pair<ll,ll> ii;

typedef vector<int> vi;

typedef long double ld; 

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

typedef set<int>::iterator sit;

typedef map<int,int>::iterator mit;

typedef vector<int>::iterator vit;



void p(ld ans)

{

	cout << fixed << setprecision(12) << ans << '\n';

}



ll x[100001];

int r[100001];

ll d[100001];

vi perm;

const int LG = 61;

int st[LG][100001];



int getval(int x, ll k)

{

	int pos = x;

	for(int i = 0; i < LG; i++)

	{

		if(k&(1LL<<i))

		{

			pos = st[i][pos];

		}	

	}

	return pos;

}



int main()

{

	ios_base::sync_with_stdio(0); cin.tie(0);

	int n; cin >> n;

	for(int i = 0; i < n; i++) cin >> x[i];

	ll m, k; cin >> m >> k;

	for(int i = 0; i < m; i++) 

	{

		cin >> r[i];

		r[i]--;

	}

	d[0] = 0;

	for(int i = 1; i < n; i++)

	{

		d[i] = x[i] - x[i-1];

	}

	for(int i = 0; i < n; i++) perm.pb(i);

	for(int i = 0; i < m; i++)

	{

		swap(perm[r[i]], perm[r[i]+1]); //check

	}

	vi perm2(n);

	for(int i = 0; i < n; i++)

	{

		perm2[perm[i]] = i;

	}

	for(int i = 0; i < n; i++)

	{

		st[0][i] = perm2[i];

	}

	for(int i = 1; i < LG; i++)

	{

		for(int j = 0; j < n; j++)

		{

			st[i][j] = st[i-1][st[i-1][j]];

		}

	}

	for(int i = 0; i < n; i++)

	{

		int pos = getval(i, k);

		perm2[pos] = i;

	}

	ld sum = ld(x[0]);

	for(int i = 0; i < n; i++)

	{

		sum += ld(d[perm2[i]]);

		p(ld(sum));

	}

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#define MAXN 100006

#include<algorithm>

using namespace std;

int n,m,id[MAXN],st[MAXN],top;

long long a[MAXN],ans[MAXN],k;

bool vis[MAXN];

int main()

{

	scanf("%d",&n);

	for(int i=1;i<=n;i++)

		scanf("%lld",&a[i]),id[i]=i;

	for(int i=n;i>=1;i--)

		a[i]-=a[i-1];

	scanf("%d%lld",&m,&k);

	for(int i=1,x;i<=m;i++)

		scanf("%d",&x),swap(id[x],id[x+1]);

	for(int i=1;i<=n;i++)

		if(!vis[i])

		{

			top=0;

			for(int j=i;!vis[j];j=id[j])

				st[++top]=j,vis[j]=1;

			for(int j=1;j<=top;j++)

				ans[st[j]]=a[st[(k+j-1)%top+1]];

		}

	for(int i=1;i<=n;i++)

	{

		ans[i]+=ans[i-1];

		printf("%lld\n",ans[i]);

	}

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



using namespace std;



typedef long long ll;



// esdgfjasgdfasjdlf

//fasdkjfajsdgfjkasdf

//flaskjdgfkjasdgfjkas

//fasdlkfgsljdf



#define MAXN 100010



ll x[MAXN], dif[MAXN], dag[MAXN], d[MAXN], cc[MAXN];

vector<ll> dor[MAXN];

ll answer[MAXN];

ll n, m, k;



int main() {

	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> n;

	for (int i = 0; i < n; i++)

		cin >> x[i];

	cin >> m >> k;

	for (int i = 1; i < n; i++)

		dif[i] = i;

	for (int i = 0; i < m; i++) {

		int z; cin >> z;

		swap(dif[z], dif[z - 1]);

	}

	for (int i = 1; i < n; i++)

		dag[dif[i]] = i;

	for (int i = 1; i < n; i++) {

		int v = i, cnt = 0;

		while (!d[v]) {

			d[v] = i; cc[v] = cnt++;

			dor[i].push_back(v);

			v = dag[v];

		}

	}

	for (int i = 1; i < n; i++) 

		answer[dor[d[i]][(k + cc[i]) % (int)dor[d[i]].size()]] = i;

	answer[0] = x[0];

	for (int i = 1; i < n; i++)

		answer[i] = answer[i - 1] - x[answer[i] - 1] + x[answer[i]];

	for (int i = 0; i < n; i++)

		cout << answer[i] << '\n';

	//system("pause");

	return 0;

}

// Optimized solution to the same problem (faster):
#include <algorithm>

#include <cstdio>

#include <cctype>

using namespace std;

typedef long long ll;

#define rg register



template <typename _Tp> inline _Tp read(_Tp&x){

	char c11=getchar(),ob=0;x=0;

	while(c11^'-'&&!isdigit(c11))c11=getchar();if(c11=='-')ob=1,c11=getchar();

	while(isdigit(c11))x=x*10+c11-'0',c11=getchar();if(ob)x=-x;return x;

}



const int N=101000;

int a[N],vis[N],st[N];

ll b[N],p[N],k;

int n,m,tp;



void init();void work();void print();

int main(){init();work();print();return 0;}



void work(){

	int x;

	for(rg int i=1;i<=m;++i)read(x),swap(a[x],a[x+1]);

	for(rg int i=1;i<=n;++i)if(!vis[i]){

		vis[st[0]=x=i]=tp=1;

		while(!vis[a[x]])

			vis[st[tp++]=x=a[x]]=1;

		int e=k%tp;

		for(rg int j=0;j<tp;++j)

			b[st[j]]=p[st[j+e<tp?j+e:j+e-tp]];

	}

}



void print(){

	ll sm(0ll);

	for(rg int i=1;i<=n;++i)

		printf("%lld\n",sm+=b[i]);

}



void init(){

	read(n);

	for(rg int i=1;i<=n;++i)read(p[i]),a[i]=i;

	for(rg int i=n;i;--i)p[i]-=p[i-1];

	read(m),read(k);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>

#include <sstream>

#include <iomanip>

#include <cstdio>

#include <cstdlib>

#include <cmath>

#include <cctype>

#include <cstring>

#include <vector>

#include <list>

#include <queue>

#include <deque>

#include <stack>

#include <map>

#include <set>

#include <algorithm>

#include <iterator>

#include <bitset>

#include <ctime>

#include<unordered_set>

#include<complex>

using namespace std;



#define FOR(i,a,b) for (int i = (a); i < (b); i++)

#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)

#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define FILL(a,value) memset(a, value, sizeof(a))



#define SZ(a) (int)a.size()

#define ALL(a) a.begin(), a.end()

#define PB push_back

#define MP make_pair



typedef long long LL;

typedef vector<int> VI;

typedef pair<int, int> PII;



const double PI = acos(-1.0);

const int INF = 1000 * 1000 * 1000 + 7;

const LL LINF = INF * (LL)INF;



const int MAX = 100000 + 47;



int X[MAX];

int DX[MAX];

int P[MAX];

int T[MAX];

int RES[MAX];

int n, m;

LL k;



void mult(int P[], int Q[])

{

	FOR(i, 0, n - 1) T[i] = Q[i];

	

	FOR(i, 0, n - 1)

	{

		P[i] = T[P[i]];

	}

}



void bp(int P[], LL k, int RES[])

{

	FOR(i, 0, n - 1) RES[i] = i;



	while (k)

	{

		if (k & 1) mult(RES, P);



		mult(P, P);

		k >>= 1;

	}

}



int main()

{

	//freopen("in.txt", "r", stdin);

	//freopen("out.txt", "w", stdout);

	ios::sync_with_stdio(false); cin.tie(0);

	cin >> n;

	FOR(i, 0, n) cin >> X[i];



	FOR(i, 0, n - 1)

	{

		DX[i] = X[i + 1] - X[i];

	}



	FOR(i, 0, n - 1)

	{

		P[i] = i;

	}



	cin >> m >> k;

	FOR(i, 0, m)

	{

		int a;

		cin >> a;

		a--;

		swap(P[a - 1], P[a]);

	}



	bp(P, k, RES);



	cout << X[0] << "\n";

	LL x = X[0];



	FOR(i, 0, n - 1)

	{

		x += DX[RES[i]];

		cout << x << "\n";

	}

}

// Optimized solution to the same problem (faster):
#include <algorithm>

#include <cstdio>

#include <cctype>

using namespace std;

typedef long long ll;

#define rg register



template <typename _Tp> inline _Tp read(_Tp&x){

	char c11=getchar(),ob=0;x=0;

	while(c11^'-'&&!isdigit(c11))c11=getchar();if(c11=='-')ob=1,c11=getchar();

	while(isdigit(c11))x=x*10+c11-'0',c11=getchar();if(ob)x=-x;return x;

}



const int N=101000;

int a[N],vis[N],st[N];

ll b[N],p[N],k;

int n,m,tp;



void init();void work();void print();

int main(){init();work();print();return 0;}



void work(){

	int x;

	for(rg int i=1;i<=m;++i)read(x),swap(a[x],a[x+1]);

	for(rg int i=1;i<=n;++i)if(!vis[i]){

		vis[st[0]=x=i]=tp=1;

		while(!vis[a[x]])

			vis[st[tp++]=x=a[x]]=1;

		int e=k%tp;

		for(rg int j=0;j<tp;++j)

			b[st[j]]=p[st[j+e<tp?j+e:j+e-tp]];

	}

}



void print(){

	ll sm(0ll);

	for(rg int i=1;i<=n;++i)

		printf("%lld\n",sm+=b[i]);

}



void init(){

	read(n);

	for(rg int i=1;i<=n;++i)read(p[i]),a[i]=i;

	for(rg int i=n;i;--i)p[i]-=p[i-1];

	read(m),read(k);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#define F(i,a,b) for(int i=(a);i<=(b);++i)

#define F2(i,a,b) for(int i=(a);i<(b);++i)

#define dF(i,a,b) for(int i=(a);i>=(b);--i)

#define dF2(i,a,b) for(int i=(a);i>(b);--i)

#define dF3(i,a,b) for(int i=(a)-1;i>=(b);--i)

using namespace std;typedef long long ll;typedef double ld;int INF=0x3f3f3f3f;int INF2=0x7fffffff;ll LNF=0x3f3f3f3f3f3f3f3f;ll LNF2=0x7fffffffffffffff;



int n,m,y;

ll k;

ll x[100001],a[100001];

ll s[100001],ans[100001],tmp[100001];



int main(){

	scanf("%d",&n);

	F(i,1,n) scanf("%lld",x+i), s[i]=i, ans[i]=i;

	dF(i,n,1) x[i]-=x[i-1];

	scanf("%d%lld",&m,&k);

	F(i,1,m) scanf("%d",&y), swap(s[y],s[y+1]);

	while(k){

		if(k&1)

			F(i,1,n) ans[i]=s[ans[i]];

		F(i,1,n) tmp[i]=s[s[i]];

		F(i,1,n) s[i]=tmp[i];

		k>>=1;

	}

	F(i,1,n) tmp[i]=x[ans[i]];

	F(i,1,n) x[i]=tmp[i];

	F(i,1,n) x[i]+=x[i-1];

	F(i,1,n) printf("%lld.0\n",x[i]);

	return 0;

}

// Optimized solution to the same problem (faster):
#include <algorithm>

#include <cstdio>

#include <cctype>

using namespace std;

typedef long long ll;

#define rg register



template <typename _Tp> inline _Tp read(_Tp&x){

	char c11=getchar(),ob=0;x=0;

	while(c11^'-'&&!isdigit(c11))c11=getchar();if(c11=='-')ob=1,c11=getchar();

	while(isdigit(c11))x=x*10+c11-'0',c11=getchar();if(ob)x=-x;return x;

}



const int N=101000;

int a[N],vis[N],st[N];

ll b[N],p[N],k;

int n,m,tp;



void init();void work();void print();

int main(){init();work();print();return 0;}



void work(){

	int x;

	for(rg int i=1;i<=m;++i)read(x),swap(a[x],a[x+1]);

	for(rg int i=1;i<=n;++i)if(!vis[i]){

		vis[st[0]=x=i]=tp=1;

		while(!vis[a[x]])

			vis[st[tp++]=x=a[x]]=1;

		int e=k%tp;

		for(rg int j=0;j<tp;++j)

			b[st[j]]=p[st[j+e<tp?j+e:j+e-tp]];

	}

}



void print(){

	ll sm(0ll);

	for(rg int i=1;i<=n;++i)

		printf("%lld\n",sm+=b[i]);

}



void init(){

	read(n);

	for(rg int i=1;i<=n;++i)read(p[i]),a[i]=i;

	for(rg int i=n;i;--i)p[i]-=p[i-1];

	read(m),read(k);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



#define f first 

#define s second 

#define pb push_back               

#define mp make_pair 



using namespace std;                    



typedef long long ll;

typedef pair<int, int> pii;

typedef pair<long long, long long> pll;



const int N = (int)1e5 + 123, mod = (int)1e9 + 7, inf = (int)1e9, LOG = 60;





ll n, m, k;

ll x[N], ans[N], a[N];

                        

int dpl[N], upl[N][LOG];

int dpr[N], upr[N][LOG];



int main(){

	srand(time(0));

    scanf("%lld", &n);       

    for(int i = 1; i <= n; i++){

    	scanf("%lld", &x[i]);

    }

    scanf("%lld%lld", &m, &k);

    for(int i = 1; i <= m; i++){

    	scanf("%lld", &a[i]);

    }



    for(int i = 1; i <= n; i++)

    	dpl[i] = dpr[i] = i;



    for(int i = 1; i <= m; i++){

    	int p = a[i];  

    	swap(dpl[p], dpl[p + 1]);

    	swap(dpr[p], dpr[p - 1]);

    }

    

    for(int i = 1;i <= n; i++)

    	upl[dpl[i]][0] = i;

    for(int i = 1; i < LOG; i++)

    	for(int j = 1; j <= n; j++)

    		upl[j][i] = upl[ upl[j][i - 1] ][i - 1];

	

	for(int i = 1;i <= n; i++)

    	upr[dpr[i]][0] = i;

    for(int i = 1; i < LOG; i++)

    	for(int j = 1; j <= n; j++)

    		upr[j][i] = upr[ upr[j][i - 1] ][i - 1];



    for(int i = 1; i <= n; i++){

    	int l = i, r = i;



    	for(int j = 0; j < LOG; j++)

    		if((1ll<<j) & k)

    			l = upl[l][j], r = upr[r][j];



    	ans[l] += x[i];

    	ans[r + 1] -= x[i];

    }



	for(int i = 1; i <= n; i++)

		printf("%lld\n", (ans[i] += ans[i - 1]));



	return 0;

}

// Optimized solution to the same problem (faster):
#include <algorithm>

#include <cstdio>

#include <cctype>

using namespace std;

typedef long long ll;

#define rg register



template <typename _Tp> inline _Tp read(_Tp&x){

	char c11=getchar(),ob=0;x=0;

	while(c11^'-'&&!isdigit(c11))c11=getchar();if(c11=='-')ob=1,c11=getchar();

	while(isdigit(c11))x=x*10+c11-'0',c11=getchar();if(ob)x=-x;return x;

}



const int N=101000;

int a[N],vis[N],st[N];

ll b[N],p[N],k;

int n,m,tp;



void init();void work();void print();

int main(){init();work();print();return 0;}



void work(){

	int x;

	for(rg int i=1;i<=m;++i)read(x),swap(a[x],a[x+1]);

	for(rg int i=1;i<=n;++i)if(!vis[i]){

		vis[st[0]=x=i]=tp=1;

		while(!vis[a[x]])

			vis[st[tp++]=x=a[x]]=1;

		int e=k%tp;

		for(rg int j=0;j<tp;++j)

			b[st[j]]=p[st[j+e<tp?j+e:j+e-tp]];

	}

}



void print(){

	ll sm(0ll);

	for(rg int i=1;i<=n;++i)

		printf("%lld\n",sm+=b[i]);

}



void init(){

	read(n);

	for(rg int i=1;i<=n;++i)read(p[i]),a[i]=i;

	for(rg int i=n;i;--i)p[i]-=p[i-1];

	read(m),read(k);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<string>

#include<algorithm>

#include<vector>

#include<iomanip>

#include<math.h>

#include<complex>

#include<queue>

#include<deque>

#include<map>

#include<set>

#include<bitset>

using namespace std;

#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )

#define rep(i,n) REP(i,0,n)

typedef long long ll;

typedef pair<int,int> pint;

const int inf=1e9+7;

const ll longinf=1LL<<60 ;

const ll mod=1e9+7 ;

int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;



int n,m,used[101010],cmp[101010];

vector<int> v[101010],rv[101010],vs;



void dfs(int x){

   used[x]=true;

   for(auto to:v[x])if(!used[to])dfs(to);

   vs.push_back(x);

}



void rdfs(int x,int k){

   used[x]=true;

   cmp[x]=k;

   for(auto to:rv[x])if(!used[to])rdfs(to,k);

}



int scc(){

   rep(i,n)if(!used[i])dfs(i);

   rep(i,n)used[i]=0;

   reverse(vs.begin(),vs.end());

   int k=0;

   for(auto x:vs)if(!used[x])rdfs(x,k++);

   return k;

}

int main(){

    cin>>n>>m;

    rep(i,m){

        int s,t;

        cin>>s>>t;

        v[s].push_back(t);

        rv[t].push_back(s);

    }

    scc();

    int q;

    cin>>q;

    rep(i,q){

        int s,t;

        cin>>s>>t;

        cout<<(cmp[s]==cmp[t])<<endl;

    }

    return 0;

}


// Optimized solution to the same problem (faster):
#include<iostream>

#include<string>

#include<algorithm>

#include<vector>

#include<iomanip>

#include<math.h>

#include<complex>

#include<queue>

#include<deque>

#include<stack>

#include<map>

#include<set>

#include<bitset>

using namespace std;

#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )

#define rep(i,n) REP(i,0,n)

typedef long long ll;

typedef pair<int,int> pint;

typedef pair<ll,int> pli;

const int inf=1e9+7;

const ll longinf=1LL<<60 ;

const ll mod=1e9+7 ;

struct StronglyConnectedComponents{

    vector<int> used,cmp,vs;

    vector<vector<int>> v,rv,g;

    StronglyConnectedComponents(int n):used(n),cmp(n,-1),v(n),rv(n){}



    void add_edge(int x,int y){

        v[x].push_back(y);

        rv[y].push_back(x);

    }

    void dfs(int x){

        used[x]=true;

        for(auto to:v[x])if(!used[to])dfs(to);

        vs.push_back(x);

    }



    void rdfs(int x,int k){

        cmp[x]=k;

        for(auto to:rv[x])if(cmp[to]==-1)rdfs(to,k);

    }



    int scc(){

        rep(i,used.size())if(!used[i])dfs(i);

        reverse(vs.begin(),vs.end());

        int k=0;

        for(auto x:vs)if(cmp[x]==-1)rdfs(x,k++);

        return k;

    }

    void build(){

        int k=scc();

        g.resize(k);

        rep(i,v.size()){

            for(auto& to:v[i]){

                int x=cmp[i],y=cmp[to];

                if(x!=y)g[x].push_back(y);

            }

        }

    }

};

int main(){

    int n,m;

    cin>>n>>m;

    StronglyConnectedComponents scc(n);

    rep(i,m){

        int x,y;

        cin>>x>>y;

        scc.add_edge(x, y);

    }

    scc.scc();

    int q;cin>>q;

    rep(i,q){

        int x,y;

        cin>>x>>y;

        cout<<(scc.cmp[x]==scc.cmp[y])<<endl;

    }

    return 0;

}




// Fastest known solution for this problem: