Language: C++

#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int Q, doubles, lengths, dat[1000009], tmp[1000009], array[1000009]; string S, T;
bool compare_suffix(int i, int j) {
    if (dat[i] == dat[j]) {
        int ri = (i + doubles <= lengths ? dat[i + doubles] : -1);
        int rj = (j + doubles <= lengths ? dat[j + doubles] : -1);
        return ri < rj;
    }
	return dat[i] < dat[j];
}
void suffix_array() {
    lengths = S.size();
    for (int i = 0; i <= lengths; i++) arrays[i] = i, dat[i] = i < lengths ? S[i] : -1;
    for (doubles = 1; doubles <= lengths; doubles <<= 1) {
        sort(arrays.begin(), arrays.begin() + lengths + 1, compare_suffix);
        tmp[arrays[0]] = 0;
        for (int i = 1; i <= lengths; i++) tmp[arrays[i]] = tmp[arrays[i - 1]] + (compare_suffix(arrays[i - 1], arrays[i]) ? 1 : 0);
        for (int i = 0; i <= lengths; i++) dat[i] = tmp[i];
    }
}
string S, T; int Q;
int main() {
    cin >> S >> Q;
    vector<int> sa = suffix_array(S);
    for (int i = 0; i < Q; i++) {
        cin >> T;
        int l = 0, r = sa.size(); bool flag = false;
        while (r - l > 1) {
            int m = (l + r) / 2;
            string S1 = S.substr(sa[m], T.size());
            if (S1 == T) {
                flag = true; break;
            }
            if (S1 < T) l = m;
            else r = m;
        }
        printf(flag ? "1\n" : "0\n");
    }
}

Compiler output:
a.cc: In function 'void suffix_array()':
a.cc:17:40: error: 'arrays' was not declared in this scope; did you mean 'array'?
   17 |     for (int i = 0; i <= lengths; i++) arrays[i] = i, dat[i] = i < lengths ? S[i] : -1;
      |                                        ^~~~~~
      |                                        array
a.cc:19:14: error: 'arrays' was not declared in this scope; did you mean 'array'?
   19 |         sort(arrays.begin(), arrays.begin() + lengths + 1, compare_suffix);
      |              ^~~~~~
      |              array
a.cc: At global scope:
a.cc:25:8: error: redefinition of 'std::string S'
   25 | string S, T; int Q;
      |        ^
a.cc:6:77: note: 'std::string S' previously declared here
    6 | int Q, doubles, lengths, dat[1000009], tmp[1000009], array[1000009]; string S, T;
      |                                                                             ^
a.cc:25:11: error: redefinition of 'std::string T'
   25 | string S, T; int Q;
      |           ^
a.cc:6:80: note: 'std::string T' previously declared here
    6 | int Q, doubles, lengths, dat[1000009], tmp[1000009], array[1000009]; string S, T;
      |                                                                                ^
a.cc:25:18: error: redefinition of 'int Q'
   25 | string S, T; int Q;
      |                  ^
a.cc:6:5: note: 'int Q' previously declared here
    6 | int Q, doubles, lengths, dat[1000009], tmp[1000009], array[1000009]; string S, T;
      |     ^
a.cc: In function 'int main()':
a.cc:28:34: error: too many arguments to function 'void suffix_array()'
   28 |     vector<int> sa = suffix_array(S);
      |                      ~~~~~~~~~~~~^~~
a.cc:15:6: note: declared here
   15 | void suffix_array() {
      |      ^~~~~~~~~~~~
a.cc:28:34: error: conversion from 'void' to non-scalar type 'std::vector<int>' requested
   28 |     vector<int> sa = suffix_array(S);
      |                      ~~~~~~~~~~~~^~~