Language: C++

import std.stdio, std.conv, std.string, std.container, std.typecons, std.algorithm;

alias Tuple!(int,int) dat;

int AlgoA(int N, int [] A, string S) {
	int cnt = 0;
	foreach(i;S) {
		if(i == 'M') cnt++;
	}
	BinaryHeap!(Array!dat) hq;
	foreach(i;0..cnt) {
		hq.insert(dat(A[i],i));
	}
	int res = 100_000;
	foreach(i;cnt..N) {
		hq.insert(dat(A[i],i));
		dat t;
		while(hq.front()[1] < i-cnt) hq.removeFront();
		res = min(res, hq.front()[0]);
	}
	return res;
}

int AlgoB(int N, int [] A, string S) {
	dat [] tmp;
	foreach(i;0..N) {
		tmp ~= dat(A[i],i);
	}
	auto hq = heapify(tmp);
	while(hq.length()) {
		dat t = hq.front();
		if( (t[1]!=0 && A[t[1]-1] > t[0]) && (t[1] != N-1 && A[t[1]+1] > t[0]) ) {
			A[t[1]] = min(A[t[1]-1], A[t[1]+1]);
		}
		hq.removeFront();
	}
	if(N % 2 == 1) {
		return A[N/2];
	}
	else {
		return max(A[N/2],A[N/2-1]);
	}
}

void main() {
	int N = to!int(readln().chomp());
	int [] A;
	A = readln().chomp().split().to!(int[]);
	auto hq = heapify(A);
	string S = readln().chomp();
	int cnt = 0;
	foreach(i;1..(N-1)) {
		if(S[i] != S[i-1]) cnt++;
	}
	if(cnt == 1 && S[0]=='M') {
		writeln(AlgoA(N,A,S));
	}
	else if(cnt == N-2 && S[0]=='M') {
		writeln(AlgoB(N,A,S));
	}
	else {
		writeln("not implemented");
	}
}


Compiler output:
a.cc:11:19: error: too many decimal points in number
   11 |         foreach(i;0..cnt) {
      |                   ^~~~~~
a.cc:26:19: error: too many decimal points in number
   26 |         foreach(i;0..N) {
      |                   ^~~~
a.cc:52:19: error: too many decimal points in number
   52 |         foreach(i;1..(N-1)) {
      |                   ^~~
a.cc:1:1: error: 'import' does not name a type
    1 | import std.stdio, std.conv, std.string, std.container, std.typecons, std.algorithm;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'alias' does not name a type
    3 | alias Tuple!(int,int) dat;
      | ^~~~~
a.cc:5:25: error: expected ',' or '...' before 'A'
    5 | int AlgoA(int N, int [] A, string S) {
      |                         ^
a.cc: In function 'int AlgoA(int, int*)':
a.cc:7:17: error: 'i' was not declared in this scope
    7 |         foreach(i;S) {
      |                 ^
a.cc:7:19: error: 'S' was not declared in this scope
    7 |         foreach(i;S) {
      |                   ^
a.cc:10:9: error: 'BinaryHeap' was not declared in this scope
   10 |         BinaryHeap!(Array!dat) hq;
      |         ^~~~~~~~~~
a.cc:11:18: error: expected ')' before ';' token
   11 |         foreach(i;0..cnt) {
      |                ~ ^
      |                  )
a.cc:14:19: error: unable to find numeric literal operator 'operator""_000'
   14 |         int res = 100_000;
      |                   ^~~~~~~
a.cc:15:18: error: expected ')' before ';' token
   15 |         foreach(i;cnt..N) {
      |                ~ ^
      |                  )
a.cc:15:23: error: expected unqualified-id before '.' token
   15 |         foreach(i;cnt..N) {
      |                       ^
a.cc: At global scope:
a.cc:24:25: error: expected ',' or '...' before 'A'
   24 | int AlgoB(int N, int [] A, string S) {
      |                         ^
a.cc: In function 'int AlgoB(int, int*)':
a.cc:25:9: error: 'dat' was not declared in this scope
   25 |         dat [] tmp;
      |         ^~~
a.cc:25:14: error: expected primary-expression before ']' token
   25 |         dat [] tmp;
      |              ^
a.cc:26:17: error: 'i' was not declared in this scope
   26 |         foreach(i;0..N) {
      |                 ^
a.cc:29:27: error: 'tmp' was not declared in this scope
   29 |         auto hq = heapify(tmp);
      |                           ^~~
a.cc:29:19: error: 'heapify' was not declared in this scope
   29 |         auto hq = heapify(tmp);
      |                   ^~~~~~~
a.cc:31:20: error: expected ';' before 't'
   31 |                 dat t = hq.front();
      |                    ^~
      |                    ;
a.cc:32:22: error: 't' was not declared in this scope
   32 |                 if( (t[1]!=0 && A[t[1]-1] > t[0]) && (t[1] != N-1 && A[t[1]+1] > t[0]) ) {
      |                      ^
a.cc:32:33: error: 'A' was not declared in this scope
   32 |                 if( (t[1]!=0 && A[t[1]-1] > t[0]) && (t[1] != N-1 && A[t[1]+1] > t[0]) ) {
      |                                 ^
a.cc:33:35: error: 'min' was not declared in this scope
   33 |                         A[t[1]] = min(A[t[1]-1], A[t[1]+1]);
      |                                   ^~~
a.cc:38:24: error: 'A' was not declared in this scope
   38 |                 return A[N/2];
      |                        ^
a.cc:41:28: error: 'A' was not declared in this scope
   41 |                 return max(A[N/2],A[N/2-1]);
      |                            ^
a.cc:41:24: error: 'max' was not declared in this scope
   41 |                 return max(A[N/2],A[N/2-1]);
      |                        ^~~
a.cc: At global scope:
a.cc:45:1: error: '::main' must return 'int'
   45 | void main() {
      | ^~~~
a.cc: In function 'int main()':
a.cc:46:17: error: 'to' was not declared in this scope
   46 |         int N = to!int(readln().chomp());
      |                 ^~
a.cc:47:13: error: structured binding declaration cannot have type 'int'
   47 |         int [] A;
      |             ^~
a.cc:47:13: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:47:13: error: empty structured binding declaration
a.cc:47:16: error: expected initializer before 'A'
   47 |         int [] A;
      |                ^
a.cc:48:9: error: 'A' was not declared in this scope
   48 |         A = readln().chomp().split().to!(int[]);
      |         ^
a.cc:48:13: error: 'readln' was not declared in this scope
   48 |         A = readln().chomp().split().to!(int[]);
      |             ^~~~~~
a.cc:49:19: error: 'heapify' was not declared in this scope
   49 |         auto hq = heapify(A);
      |                   ^~~~~~~
a.cc:50:9: error: 'string' was not declared in this scope
   50 |         string S = readln().chomp();
      |         ^~~~~~
a.cc:52:17: error: 'i' was not declared in this scope
   52 |         foreach(i;1..(N-1)) {
      |                 ^
a.cc:55:24: error: 'S' was not declared in this scope
   55 |         if(cnt == 1 && S[0]=='M') {
      |                        ^
a.cc:56:17: error: 'writeln' was not declared in this scope
   56 |                 writeln(AlgoA(N,A,S));
      |                 ^~~~~~~
a.cc:59:17: error: 'writeln' was not declared in this scope
   59 |                 writeln(AlgoB(N,A,S));
      |                 ^~~~~~~
a.cc:62:17: error: 'writeln' was not declared in this scope
   62 |                 writeln("not implemented");
      |                 ^~~~~~~