Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <fstream>
#include <bitset>
#include <cstdio>
#include <sstream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <set>
#include <cctype>
#include <iomanip>
#include <list>
#include <cstring>

#define INF 2000000000
#define ull unsigned long long int
#define vi vector<int>
#define vii vector<ii>

#define UNVISITED 0
#define OPENED 1
#define CLOSED 2

#define PI 3.14159


using namespace std;

int array[64];


int n, q;
int arrayToTree[128];
int tree[128];

int left(int a) {
    return ( a << 1);
}

int right(int a) {
    return ((a << 1) +1);
}

int build(int node, int l, int r) {
    
    if(l == r) {
        tree[node] = array[l];
        arrayToTree[l]= node;
    }
    else {
        tree[node] =  max(build(left(node), l, (l+r)/2), build(right(node), (l+r)/2+1, r));
    }

    return tree[node];
}

int rq(int node, int l, int r, int x, int y) {

    if(l > y || r < x) return 0;

    if(l >= x && r <= y) return tree[node];

    return max(rq(left(node), l, (l+r)/2,x, y),rq(right(node), (l+r)/2+1, r, x, y));



}

int req(int x, int y) {

    return rq(1, 1, 26, x, y);

}

void updateTree(int node) {
    tree[node] = max(tree[left(node)],tree[right(node)]);
    if(node <= 1) return;
    updateTree(node/2);

}

int update(int x, int a) {
    
    array[x] = a;
    tree[arrayToTree[x]] = a,
    updateTree(arrayToTree[x]/2);


}

int main () {
    
    string s;   
    cin >> s;
    build(1, 1, 26);  

    int lower = 1, upper = 1;
    update(s[0]-'a'+1, 1);

    bool ok = false;

    while(lower <= s.size()) {
        int r = req(1, 26);

        if(r < (upper-lower)/2) {
            update(s[lower-1]-'a'+1, array[(s[lower-1]-'a'+1)]-1);
            lower++;
        }
        else if(upper < s.size()-1){
            update(s[upper]-'a'+1, array[(s[upper]-'a'+1)]+1);
            upper++;

        }
        else {
        
            update(s[lower-1]-'a'+1, array[(s[lower-1]-'a'+1)]-1);
            lower++;
        }
        
        if(r > (upper - lower + 1)/2 && r >= 2) {
            cout << lower << " " << upper << endl;
            ok = true;
            break;
        }


    } 

    if(!ok) cout << "-1 -1" << endl;

   
 

    return 0;
}


Compiler output:
a.cc: In function 'int build(int, int, int)':
a.cc:51:22: error: reference to 'array' is ambiguous
   51 |         tree[node] = array[l];
      |                      ^~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 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_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:33:5: note:                 'int array [64]'
   33 | int array[64];
      |     ^~~~~
a.cc: In function 'int update(int, int)':
a.cc:88:5: error: reference to 'array' is ambiguous
   88 |     array[x] = a;
      |     ^~~~~
/usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:33:5: note:                 'int array [64]'
   33 | int array[64];
      |     ^~~~~
a.cc:93:1: warning: no return statement in function returning non-void [-Wreturn-type]
   93 | }
      | ^
a.cc: In function 'int main()':
a.cc:110:38: error: reference to 'array' is ambiguous
  110 |             update(s[lower-1]-'a'+1, array[(s[lower-1]-'a'+1)]-1);
      |                                      ^~~~~
/usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:33:5: note:                 'int array [64]'
   33 | int array[64];
      |     ^~~~~
a.cc:114:36: error: reference to 'array' is ambiguous
  114 |             update(s[upper]-'a'+1, array[(s[upper]-'a'+1)]+1);
      |                                    ^~~~~
/usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:33:5: note:                 'int array [64]'
   33 | int array[64];
      |     ^~~~~
a.cc:120:38: error: reference to 'array' is ambiguous
  120 |             update(s[lower-1]-'a'+1, array[(s[lower-1]-'a'+1)]-1);
      |                                      ^~~~~
/usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:33:5: note:                 'int array [64]'
   33 | int array[64];
      |     ^~~~~