Language: C++

#include <bits/stdc++.h> 
#define Rint register int
#define LL long long
#define F(x,y,z) for(Rint x=y;x<=z;++x)
#define D(x,y,z) for(Rint x=y;x>=z;--x)
using namespace std;
LL Min(LL x,LL y){return x<y?x:y;}
LL Max(LL x,LL y){return x>y?x:y;}
inline LL R(){
    char c='!';LL x=0,z=1;
    for( ; c>'9'||c<'0';c=getchar()) if(c=='-')z=-1;
    for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';
    return x*z;
}
const int N=400010;
int n,m,countt;
char s[200010];
int to[N],ne[N],st[N],sl;
int ys[N],cnta,cntb,a[N],b[N];
bitset<100010> p[200010],b1,b2;
void Ads(int x,int y){
	to[++sl]=y;ne[sl]=st[x];st[x]=sl;
}

int main(){
	n=R();m=R();
	cin>>s;
	D(i,n,1)s[i]=s[i-1];
	F(i,1,n) countt+=s[i]=='B';
	if (countt>100000)
		F(i,1,n) s[i]=s[i]=='A'?'B':'A';
	F(i,1,n) if (s[i]=='A') ys[i]=++cnta;else ys[i]=++cntb;
	F(i,1,m){
		int x=R(),y=R();
		a[i]=x;b[i]=y;
		Ads(x,y);Ads(y,x);
	}
	F(u,1,n){
		if (s[u]=='A') continue;
		for (int i=st[u];i;i=ne[i])
			if (s[to[i]]=='A')p[ys[u]][ys[to[i]]]=1;
	}
	F(i,1,m)
		if (s[a[i]]=='B'&&s[b[i]]=='B'){
			b1=p[ys[a[i]]]&p[ys[b[i]]];
			if (!b1.none()){
				printf("Yes\n");
				return 0;
			}
		}
	printf("No\n");
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:11: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   28 |         D(i,n,1)s[i]=s[i-1];
      |           ^
a.cc:5:27: note: in definition of macro 'D'
    5 | #define D(x,y,z) for(Rint x=y;x>=z;--x)
      |                           ^
a.cc:29:11: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   29 |         F(i,1,n) countt+=s[i]=='B';
      |           ^
a.cc:4:27: note: in definition of macro 'F'
    4 | #define F(x,y,z) for(Rint x=y;x<=z;++x)
      |                           ^
a.cc:31:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   31 |                 F(i,1,n) s[i]=s[i]=='A'?'B':'A';
      |                   ^
a.cc:4:27: note: in definition of macro 'F'
    4 | #define F(x,y,z) for(Rint x=y;x<=z;++x)
      |                           ^
a.cc:32:11: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   32 |         F(i,1,n) if (s[i]=='A') ys[i]=++cnta;else ys[i]=++cntb;
      |           ^
a.cc:4:27: note: in definition of macro 'F'
    4 | #define F(x,y,z) for(Rint x=y;x<=z;++x)
      |                           ^
a.cc:33:11: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   33 |         F(i,1,m){
      |           ^
a.cc:4:27: note: in definition of macro 'F'
    4 | #define F(x,y,z) for(Rint x=y;x<=z;++x)
      |                           ^
a.cc:38:11: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   38 |         F(u,1,n){
      |           ^
a.cc:4:27: note: in definition of macro 'F'
    4 | #define F(x,y,z) for(Rint x=y;x<=z;++x)
      |                           ^
a.cc:43:11: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   43 |         F(i,1,m)
      |           ^
a.cc:4:27: note: in definition of macro 'F'
    4 | #define F(x,y,z) for(Rint x=y;x<=z;++x)
      |                           ^
/tmp/ccYkAkaJ.o: in function `main':
a.cc:(.text+0x4b6): relocation truncated to fit: R_X86_64_PC32 against symbol `b1' defined in .bss section in /tmp/ccYkAkaJ.o
a.cc:(.text+0x4d4): relocation truncated to fit: R_X86_64_PC32 against symbol `b1' defined in .bss section in /tmp/ccYkAkaJ.o
collect2: error: ld returned 1 exit status