Language: C++

#include<bits/stdc++.h>
#define INF 10e8
using namespace std;
int i,j,k,n,m,d[10000],s,left[10000],right[10000],x,flg[100000]={0},ans,rr,ll;
int main(void)
{
	
	cin>>n>>m>>s;
	for(i=0;i<m;i++) cin>>d[i],flg[d[i]]=1;
	ans=x=0;
	for(i=s;i<n;i++) {
		if(flg[i]==1) {
			ll=i;
			break;
		}
		if(i+1==n) i=-1;
	}
	for(i=s;i>=0;i--) {
		if(flg[i]==1) {
			rr=i;
			break;
		}
		if(i-1<0) i=n;
	}
	for(i=s;i<n;i++) {
		if(rr==i) break;
		if(i+1==n) i=-1;
		ans++;
	}
	for(i=s;i>=0;i--) {
		if(ll==i) break;
		if(i-1<0) i=n;
		x++;
		
	}
	sort(d,d+m);
	for(i=0;i<m-1;i++) right[d[i]]=d[i+1];
	right[d[m-1]]=d[0];
	for(i=m-1;i>=1;i--) left[d[i]]=d[i-1];
	left[d[0]]=d[m-1];
	right[s]=rr,left[s]=ll;
	ans=min(ans,x);
	int ff,a,b,c;
	for(i=s;i<n;i++) {
		if(flg[i]==1&&right[s]!=i) {
			a=i-s;
			b=s-right[i];
			if(a<0&&b>0) a+=n;
			else if(a>0&&b<0) b+=n;
			a*=2;
			ans=min(ans,a+b);
		}
		else if (d[m-1]==i) break;
		if(i+1==n) i=-1;
	}
	for(i=s;i>=0;i--) {
		if(flg[i]==1&&left[s]!=i){
			a=s-i;
			b=left[i]-s;
			if(a<0&&b>0) a+=n;
			else if(a>0&&b<0) b+=n;
			a*=2;
			ans=min(ans,a+b);
		}
		else if (d[0]==i) break;
		if(i-1<0) i=n;
	}
	cout<<ans*100<<endl;
}
	
	

Compiler output:
a.cc: In function 'int main()':
a.cc:37:28: error: reference to 'right' is ambiguous
   37 |         for(i=0;i<m-1;i++) right[d[i]]=d[i+1];
      |                            ^~~~~
In file included from /usr/include/c++/14/streambuf:43,
                 from /usr/include/c++/14/bits/streambuf_iterator.h:35,
                 from /usr/include/c++/14/iterator:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54,
                 from a.cc:1:
/usr/include/c++/14/bits/ios_base.h:1070:3: note: candidates are: 'std::ios_base& std::right(ios_base&)'
 1070 |   right(ios_base& __base)
      |   ^~~~~
a.cc:4:38: note:                 'int right [10000]'
    4 | int i,j,k,n,m,d[10000],s,left[10000],right[10000],x,flg[100000]={0},ans,rr,ll;
      |                                      ^~~~~
a.cc:38:9: error: reference to 'right' is ambiguous
   38 |         right[d[m-1]]=d[0];
      |         ^~~~~
/usr/include/c++/14/bits/ios_base.h:1070:3: note: candidates are: 'std::ios_base& std::right(ios_base&)'
 1070 |   right(ios_base& __base)
      |   ^~~~~
a.cc:4:38: note:                 'int right [10000]'
    4 | int i,j,k,n,m,d[10000],s,left[10000],right[10000],x,flg[100000]={0},ans,rr,ll;
      |                                      ^~~~~
a.cc:39:29: error: reference to 'left' is ambiguous
   39 |         for(i=m-1;i>=1;i--) left[d[i]]=d[i-1];
      |                             ^~~~
/usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)'
 1062 |   left(ios_base& __base)
      |   ^~~~
a.cc:4:26: note:                 'int left [10000]'
    4 | int i,j,k,n,m,d[10000],s,left[10000],right[10000],x,flg[100000]={0},ans,rr,ll;
      |                          ^~~~
a.cc:40:9: error: reference to 'left' is ambiguous
   40 |         left[d[0]]=d[m-1];
      |         ^~~~
/usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)'
 1062 |   left(ios_base& __base)
      |   ^~~~
a.cc:4:26: note:                 'int left [10000]'
    4 | int i,j,k,n,m,d[10000],s,left[10000],right[10000],x,flg[100000]={0},ans,rr,ll;
      |                          ^~~~
a.cc:41:9: error: reference to 'right' is ambiguous
   41 |         right[s]=rr,left[s]=ll;
      |         ^~~~~
/usr/include/c++/14/bits/ios_base.h:1070:3: note: candidates are: 'std::ios_base& std::right(ios_base&)'
 1070 |   right(ios_base& __base)
      |   ^~~~~
a.cc:4:38: note:                 'int right [10000]'
    4 | int i,j,k,n,m,d[10000],s,left[10000],right[10000],x,flg[100000]={0},ans,rr,ll;
      |                                      ^~~~~
a.cc:41:21: error: reference to 'left' is ambiguous
   41 |         right[s]=rr,left[s]=ll;
      |                     ^~~~
/usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)'
 1062 |   left(ios_base& __base)
      |   ^~~~
a.cc:4:26: note:                 'int left [10000]'
    4 | int i,j,k,n,m,d[10000],s,left[10000],right[10000],x,flg[100000]={0},ans,rr,ll;
      |                          ^~~~
a.cc:45:31: error: reference to 'right' is ambiguous
   45 |                 if(flg[i]==1&&right[s]!=i) {
      |                               ^~~~~
/usr/include/c++/14/bits/ios_base.h:1070:3: note: candidates are: 'std::ios_base& std::right(ios_base&)'
 1070 |   right(ios_base& __base)
      |   ^~~~~
a.cc:4:38: note:                 'int right [10000]'
    4 | int i,j,k,n,m,d[10000],s,left[10000],right[10000],x,flg[100000]={0},ans,rr,ll;
      |                                      ^~~~~
a.cc:47:29: error: reference to 'right' is ambiguous
   47 |                         b=s-right[i];
      |                             ^~~~~
/usr/include/c++/14/bits/ios_base.h:1070:3: note: candidates are: 'std::ios_base& std::right(ios_base&)'
 1070 |   right(ios_base& __base)
      |   ^~~~~
a.cc:4:38: note:                 'int right [10000]'
    4 | int i,j,k,n,m,d[10000],s,left[10000],right[10000],x,flg[100000]={0},ans,rr,ll;
      |                                      ^~~~~
a.cc:57:31: error: reference to 'left' is ambiguous
   57 |                 if(flg[i]==1&&left[s]!=i){
      |                               ^~~~
/usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)'
 1062 |   left(ios_base& __base)
      |   ^~~~
a.cc:4:26: note:                 'int left [10000]'
    4 | int i,j,k,n,m,d[10000],s,left[10000],right[10000],x,flg[100000]={0},ans,rr,ll;
      |                          ^~~~
a.cc:59:27: error: reference to 'left' is ambiguous
   59 |                         b=left[i]-s;
      |                           ^~~~
/usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)'
 1062 |   left(ios_base& __base)
      |   ^~~~
a.cc:4:26: note:                 'int left [10000]'
    4 | int i,j,k,n,m,d[10000],s,left[10000],right[10000],x,flg[100000]={0},ans,rr,ll;
      |                          ^~~~