Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
struct node
{
	int x,y,newy;
	bool operator < (const node &a)const
	{
		if (x!=a.x)
			return x<a.x;
		else
			return newy>a.newy;
	}
};
node move[1000001];
int f[1000001],c[1000001],a[1000001],b[1000001],ans,res,len,n,m,useless;
bool cmp(node u,node v)
{
	return u.y<v.y;
}
int lowbit(int x)
{
	return x&(-x);
}
void add(int x,int d)
{
	for (;x<=n;x+=lowbit(x))
		c[x]+=d;
	return;
}
int sum(int x)
{
	ans=0;
	for (;x>=1;x-=lowbit(x))
		ans+=c[x];
	return ans;
}
int main()
{
	int first,last,mid,front,back;
	cin>>n>>m;
	for (int i=1;i<=n;++i)
		cin>>a[i];
	for (int i=1;i<=m;++i)
		cin>>b[i];
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	for (int i=1;i<=n;++i)
	{
		first=1;
		last=m;
		front=0;
		back=m+1;
		while (first<=last)
		{
			mid=(first+last)/2;
			if (a[i]>=b[mid])
			{
				front=max(front,mid);
				first=mid+1;
			}
			else
				last=mid-1;
		}
		first=1;
		last=m;
		while (first<=last)
		{
			mid=(first+last)/2;
			if (a[i]<=b[mid])
			{
				back=min(back,mid);
				last=mid-1;
			}
			else
				first=mid+1;
		}
		if (front==0||back==m+1||b[front]==a[i]||b[back]==a[i])
			continue;
		move[++len].x=a[i]-b[front];
		move[len].y=b[back]-a[i];
	}
	sort(move+1,move+len+1,cmp);
	for (int i=1;i<=len;++i)
	{
		move[i].newy=i-useless;
		if (move[i].y==move[i+1].y)
			useless++;
	}
	sort(move+1,move+len+1);
	for (int i=1;i<=len;++i)
	{
		f[i]=sum(move[i].newy-1)+1;
		add(move[i].newy,f[i]);
	}
	for (int i=1;i<=len;++i)
		res+=f[i];
	cout<<res+1<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:80:17: error: reference to 'move' is ambiguous
   80 |                 move[++len].x=a[i]-b[front];
      |                 ^~~~
In file included from /usr/include/c++/14/algorithm:86,
                 from a.cc:2:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
  353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
      | ^~~~
In file included from /usr/include/c++/14/string:51,
                 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_algobase.h:675:5: note:                 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
  675 |     move(_II __first, _II __last, _OI __result)
      |     ^~~~
In file included from /usr/include/c++/14/bits/exception_ptr.h:41,
                 from /usr/include/c++/14/exception:166,
                 from /usr/include/c++/14/ios:41:
/usr/include/c++/14/bits/move.h:137:5: note:                 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
  137 |     move(_Tp&& __t) noexcept
      |     ^~~~
a.cc:15:6: note:                 'node move [1000001]'
   15 | node move[1000001];
      |      ^~~~
a.cc:81:17: error: reference to 'move' is ambiguous
   81 |                 move[len].y=b[back]-a[i];
      |                 ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
  353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
      | ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note:                 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
  675 |     move(_II __first, _II __last, _OI __result)
      |     ^~~~
/usr/include/c++/14/bits/move.h:137:5: note:                 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
  137 |     move(_Tp&& __t) noexcept
      |     ^~~~
a.cc:15:6: note:                 'node move [1000001]'
   15 | node move[1000001];
      |      ^~~~
a.cc:83:14: error: reference to 'move' is ambiguous
   83 |         sort(move+1,move+len+1,cmp);
      |              ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
  353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
      | ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note:                 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
  675 |     move(_II __first, _II __last, _OI __result)
      |     ^~~~
/usr/include/c++/14/bits/move.h:137:5: note:                 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
  137 |     move(_Tp&& __t) noexcept
      |     ^~~~
a.cc:15:6: note:                 'node move [1000001]'
   15 | node move[1000001];
      |      ^~~~
a.cc:83:21: error: reference to 'move' is ambiguous
   83 |         sort(move+1,move+len+1,cmp);
      |                     ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
  353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
      | ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note:                 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
  675 |     move(_II __first, _II __last, _OI __result)
      |     ^~~~
/usr/include/c++/14/bits/move.h:137:5: note:                 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
  137 |     move(_Tp&& __t) noexcept
      |     ^~~~
a.cc:15:6: note:                 'node move [1000001]'
   15 | node move[1000001];
      |      ^~~~
a.cc:86:17: error: reference to 'move' is ambiguous
   86 |                 move[i].newy=i-useless;
      |                 ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
  353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
      | ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note:                 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
  675 |     move(_II __first, _II __last, _OI __result)
      |     ^~~~
/usr/include/c++/14/bits/move.h:137:5: note:                 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
  137 |     move(_Tp&& __t) noexcept
      |     ^~~~
a.cc:15:6: note:                 'node move [1000001]'
   15 | node move[1000001];
      |      ^~~~
a.cc:87:21: error: reference to 'move' is ambiguous
   87 |                 if (move[i].y==move[i+1].y)
      |                     ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
  353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
      | ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note:                 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
  675 |     move(_II __first, _II __last, _OI __result)
      |     ^~~~
/usr/include/c++/14/bits/move.h:137:5: note:                 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
  137 |     move(_Tp&& __t) noexcept
      |     ^~~~
a.cc:15:6: note:                 'node move [1000001]'
   15 | node move[1000001];
      |      ^~~~
a.cc:87:32: error: reference to 'move' is ambiguous
   87 |                 if (move[i].y==move[i+1].y)
      |                                ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
  353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
      | ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note:                 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
  675 |     move(_II __first, _II __last, _OI __result)
      |     ^~~~
/usr/include/c++/14/bits/move.h:137:5: note:                 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
  137 |     move(_Tp&& __t) noexcept
      |     ^~~~
a.cc:15:6: note:                 'node move [1000001]'
   15 | node move[1000001];
      |      ^~~~
a.cc:90:14: error: reference to 'move' is ambiguous
   90 |         sort(move+1,move+len+1);
      |              ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
  353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
      | ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note:                 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
  675 |     move(_II __first, _II __last, _OI __result)
      |     ^~~~
/usr/include/c++/14/bits/move.h:137:5: note:                 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
  137 |     move(_Tp&& __t) noexcept
      |     ^~~~
a.cc:15:6: note:                 'node move [1000001]'
   15 | node move[1000001];
      |      ^~~~
a.cc:90:21: error: reference to 'move' is ambiguous
   90 |         sort(move+1,move+len+1);
      |                     ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
  353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
      | ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: