Language: C++

#include <bits/stdc++.h>
using namespace std;
const int maxn=100100;

struct tree {
	int ma,mi,add;
}d[maxn<<2];
struct ques {
	int t,a,id,ans;
}q[maxn];
int n,m,Q,st=1,now;
int t[maxn],hash[maxn],ans[maxn];

void pushdown(int o)
{
	int ls=o<<1,rs=o<<1|1;
	d[ls].add+=d[o].add; d[rs].add+=d[o].add;
	if (d[o].ma) d[ls].ma=d[o].ma,d[rs].ma=d[o].ma;
	if (d[o].mi) d[ls].mi=d[o].mi,d[rs].mi=d[o].mi;
	d[o].add=d[o].ma=d[o].mi=0;
}

void change(int o,int L,int R,int l,int r,int val,int flag)
{
	if (l<=L && r>=R)
	{
		d[o].add+=val*flag;
		if (flag==1) d[o].ma=1; else d[o].mi=1;
		return;
	}
	int mid=(L+R)>>1;
	if (l<=mid) change(o<<1,L,mid,l,r,val,flag);
	if (r>mid) change(o<<1|1,mid+1,R,l,r,val,flag);
}

void down(int o,int l,int r)
{
	if (l==r)
	{
		if (l<st) return;
		ans[l]+=d[o].add; d[o].add=0;
		if (d[o].ma) ans[l]=min(ans[l],n);
		else ans[l]=max(ans[l],0);
		d[o].ma=d[o].mi=0;
		return;
	}
	pushdown(o);
	int mid=(l+r)>>1;
	down(o<<1,l,mid);
	down(o<<1|1,mid+1,r);
}

int main()
{
	scanf("%d",&n); scanf("%d",&m);
	for (int i=1;i<=m;i++) scanf("%d",&t[i]);
	
	scanf("%d",&Q);
	for (int i=1;i<=Q;i++)
	{
		scanf("%d%d",&q[i].t,&q[i].a);
		ans[i]=q[i].a;
		hash[i]=q[i].t;
	}
	
	for (int i=1;i<=m;i++)
	{
		int pos=lower_bound(hash+1,hash+Q+1,t[i])-hash-1;
		while (st<=pos)
		{
			if (!now) ans[st]=max(ans[st]-(q[st].t-t[i-1]),0);
			else ans[st]=min(ans[st]+(q[st].t-t[i-1]),n);
			st++;
		}
		if (!now) change(1,1,Q,st,Q,t[i]-t[i-1],-1);
		else change(1,1,Q,st,Q,t[i]-t[i-1],1);
		down(1,1,Q);
		now^=1;
	}
	while (st<=Q)
	{
		if (!now) ans[st]=max(ans[st]-(q[st].t-t[m]),0);
		else ans[st]=min(ans[st]+(q[st].t-t[m]),n);
		st++;
	}
	
	for (int i=1;i<=Q;i++) printf("%d\n",ans[i]);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:63:17: error: reference to 'hash' is ambiguous
   63 |                 hash[i]=q[i].t;
      |                 ^~~~
In file included from /usr/include/c++/14/string_view:50,
                 from /usr/include/c++/14/bits/basic_string.h:47,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:12:13: note:                 'int hash [100100]'
   12 | int t[maxn],hash[maxn],ans[maxn];
      |             ^~~~
a.cc:68:37: error: reference to 'hash' is ambiguous
   68 |                 int pos=lower_bound(hash+1,hash+Q+1,t[i])-hash-1;
      |                                     ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:12:13: note:                 'int hash [100100]'
   12 | int t[maxn],hash[maxn],ans[maxn];
      |             ^~~~
a.cc:68:44: error: reference to 'hash' is ambiguous
   68 |                 int pos=lower_bound(hash+1,hash+Q+1,t[i])-hash-1;
      |                                            ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:12:13: note:                 'int hash [100100]'
   12 | int t[maxn],hash[maxn],ans[maxn];
      |             ^~~~
a.cc:68:59: error: reference to 'hash' is ambiguous
   68 |                 int pos=lower_bound(hash+1,hash+Q+1,t[i])-hash-1;
      |                                                           ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:12:13: note:                 'int hash [100100]'
   12 | int t[maxn],hash[maxn],ans[maxn];
      |             ^~~~